TEST(EdgeTest, TcpFail) { Timer::GetInstance().UseRealTime(); const TcpAddress addr("127.0.0.1", 33347); TcpEdgeListener te(addr); te.Start(); MockEdgeHandler meh(&te); SignalCounter sc(1); QObject::connect(&te, SIGNAL(EdgeCreationFailure(const Address &, const QString &)), &sc, SLOT(Counter())); TcpAddress any; te.CreateEdgeTo(any); MockExecLoop(sc); EXPECT_EQ(sc.GetCount(), 1); sc.Reset(); TcpAddress other_addr("255.255.255.255.", 1111); te.CreateEdgeTo(other_addr); MockExecLoop(sc); EXPECT_EQ(sc.GetCount(), 1); sc.Reset(); TcpAddress bad_addr(QUrl("tcp://ha!")); te.CreateEdgeTo(bad_addr); MockExecLoop(sc); EXPECT_EQ(sc.GetCount(), 1); sc.Reset(); TcpAddress another_addr("5.5.5.5", 12345); te.CreateEdgeTo(another_addr); MockExecLoop(sc); EXPECT_EQ(sc.GetCount(), 1); }
int main(int argc, char **argv) { int f = open("kid-shirou.code", O_RDONLY); if (f == -1) { die("Failed to open the file"); } /* oh, right, this is what makes it terrible to do this: I need the length of the file. well, screw using fstat. time to hard code. */ void *x = mmap(0, 311, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FILE|MAP_PRIVATE, f, 0); /* hmm. is there a subtle conflict if I open a file RDONLY, but mmap it with writability? if I use MAP_PRIVATE, it shouldn't be trying to modify the file itself, so it seems that *should* be fine... we will try, I suppose */ void *a = dlopen; void *b = dlsym; void (*meh)(void *, void *) = x; printf("Allocated: a %p b %p meh %p\n", a, b, meh); meh(a,b); return 0; }
void bar() { foo x; meh(); }