示例#1
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            await Task.Yield();

            var ta = new TestArgs(args);

            var s = ta.AE;
            var t = ta.BE;
            var a = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                new XLogCfg("a-SimpleExchange", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-SimpleExchange", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            const string ADD_ONE = "addOne";

            try
            {
                b.RegisterAPI(ADD_ONE, add_one);

                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                using (var ix = await a.Request(ADD_ONE, 3))
                    if (!ix.IsOK || ix.Make <int>() != 4)
                    {
                        Passed         = false;
                        FailureMessage = "Request failure.";
                        return;
                    }

                Passed     = true;
                IsComplete = true;
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
            }
        }
示例#2
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            var ta = new TestArgs(args);

            var s = ta.AE;
            var t = ta.BE;

            var a = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                new XLogCfg("a-ResNotFound", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-ResNotFound", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            try
            {
                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                using (var ix = await a.Request("NonExistingResKey", 3))
                    if (!ix.IsOK && ix.ErrorCode == (int)XErrorCode.ResourceNotFound)
                    {
                        Passed     = true;
                        IsComplete = true;
                    }

                if (!Passed.HasValue)
                {
                    Passed = false;
                }
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
            }
        }
示例#3
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            var ta = new TestArgs(args);

            var s = ta.AE;
            var t = ta.BE;

            var a = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                new XLogCfg("a-RemoteException", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-RemoteException", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            try
            {
                string RES = "WillThrow";

                b.RegisterAPI(RES, (f) =>
                {
                    "Throwing NotSupportedException".AsInfo();

                    throw new NotSupportedException();
                });

                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                using (var ix = await a.Request(RES))
                    if (!ix.IsOK && ix.ErrorCode == (int)XErrorCode.SerializedException)
                    {
                        var ex = ix.Make <Exception>();

                        if (ex is NotSupportedException)
                        {
                            Passed     = true;
                            IsComplete = true;
                        }
                    }

                if (!Passed.HasValue)
                {
                    Passed = false;
                }
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
            }
        }
示例#4
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            var ta = new TestArgs(args);
            var s  = ta.AE;
            var t  = ta.BE;
            var a  = new XPU(new XCfg(
                                 new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                 new XLogCfg("a-Replies", ta.Log),
                                 new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-Replies", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            MarshalSlot ms = null;

            try
            {
                b.RegisterAPI("ep", entry_point);

                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                ms = MarshalSlot.Store(8);

                var x = await a.RawRequest("ep", ms, false, TIMEOUT);

                int data = 0;
                x.Fragment.Read(ref data, x.DataOffset);

                while (data > 0 && !x.DoNotReply)
                {
                    data--;
                    ms.Write(data, 0);

                    x = await x.RawReply(ms, data < 1, true, TIMEOUT);

                    if (!x.IsOK)
                    {
                        Passed         = false;
                        FailureMessage = "Timeout";
                        return;
                    }

                    if (x.State == XState.Beamed)
                    {
                        x.Fragment.Read(ref data, x.DataOffset);
                    }
                }

                await Task.Delay(TIMEOUT.Milliseconds * 3);

                if (!Passed.HasValue)
                {
                    Passed     = true;
                    IsComplete = true;
                }
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
                ms.Dispose();
            }
        }