From db58b73bde1433784a2a3d72ddef760b3fb320c0 Mon Sep 17 00:00:00 2001 From: Joseph Malloch Date: Wed, 6 Nov 2024 11:37:39 -0400 Subject: [PATCH 1/2] cpp_test: Added missing path slash characters. --- src/cpp_test.cpp | 127 ++++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/src/cpp_test.cpp b/src/cpp_test.cpp index 003d4ed3..2ee41894 100644 --- a/src/cpp_test.cpp +++ b/src/cpp_test.cpp @@ -63,68 +63,68 @@ void init(lo::Server &s) int _j; }; - s.add_method("test0", "i", test3(j,"test0")); - s.del_method("test0", "i"); + s.add_method("/test0", "i", test3(j,"/test0")); + s.del_method("/test0", "i"); - s.add_method("test1", "i", test1, 0); - s.add_method("test2", "i", test2); - s.add_method("test3", "i", test3(j, "test3")); + s.add_method("/test1", "i", test1, 0); + s.add_method("/test2", "i", test2); + s.add_method("/test3", "i", test3(j, "/test3")); - s.add_method("test4", "i", - [j](lo_arg **argv, int argc) - { - printf("test4: %d, %d\n", j, argv[0]->i); - return 0; - }); + s.add_method("/test4", "i", + [j](lo_arg **argv, int argc) + { + printf("/test4: %d, %d\n", j, argv[0]->i); + return 0; + }); j *= 2; - s.add_method("test5", "i", - [j](lo_arg **argv, int argc, lo_message msg) - { - printf("test5: %d, %d -- ", j, argv[0]->i); - lo_message_pp(msg); - return 0; - }); + s.add_method("/test5", "i", + [j](lo_arg **argv, int argc, lo_message msg) + { + printf("/test5: %d, %d -- ", j, argv[0]->i); + lo_message_pp(msg); + return 0; + }); j *= 2; - s.add_method("test6", "i", - [j](lo_message msg) - { - printf("test6: %d -- ", j); - lo_message_pp(msg); - return 0; - }); + s.add_method("/test6", "i", + [j](lo_message msg) + { + printf("/test6: %d -- ", j); + lo_message_pp(msg); + return 0; + }); j *= 2; - s.add_method("test7", "i", [j](){printf("test7: %d\n", j); return 0;}); + s.add_method("/test7", "i", [j](){printf("/test7: %d\n", j); return 0;}); j *= 2; - s.add_method("test8", "i", [j](){printf("test8a: %d\n", j);}); + s.add_method("/test8", "i", [j](){printf("/test8a: %d\n", j);}); j *= 2; - s.add_method("test8", "i", [j](){printf("test8b: %d\n", j);}); + s.add_method("/test8", "i", [j](){printf("/test8b: %d\n", j);}); j*=2; - s.add_method("test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc) - {printf("test9.1: %d, %s, %s, %d\n", j, path, types, argv[0]->i); return 1;}); + s.add_method("/test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc) + {printf("/test9.1: %d, %s, %s, %d\n", j, path, types, argv[0]->i); return 1;}); j*=2; - s.add_method("test10", "i", [j](const char *types, lo_arg **argv, int argc) - {printf("test10.1: %d, %s, %d\n", j, types, argv[0]->i); return 1;}); + s.add_method("/test10", "i", [j](const char *types, lo_arg **argv, int argc) + {printf("/test10.1: %d, %s, %d\n", j, types, argv[0]->i); return 1;}); j*=2; - s.add_method("test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg) - {printf("test11.1: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg); return 1;}); + s.add_method("/test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg) + {printf("/test11.1: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg); return 1;}); j*=2; - s.add_method("test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc) - {printf("test9.2: %d, %s, %s, %d\n", j, path, types, argv[0]->i);}); + s.add_method("/test9", "i", [j](const char *path, const char *types, lo_arg **argv, int argc) + {printf("/test9.2: %d, %s, %s, %d\n", j, path, types, argv[0]->i);}); j*=2; - s.add_method("test10", "i", [j](const char *types, lo_arg **argv, int argc) - {printf("test10.2: %d, %s, %d\n", j, types, argv[0]->i);}); + s.add_method("/test10", "i", [j](const char *types, lo_arg **argv, int argc) + {printf("/test10.2: %d, %s, %d\n", j, types, argv[0]->i);}); j*=2; - s.add_method("test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg) - {printf("test11.2: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg);}); + s.add_method("/test11", "is", [j](const char *types, lo_arg **argv, int argc, lo_message msg) + {printf("/test11.2: %d, %s, %d, %s -- ", j, types, argv[0]->i, &argv[1]->s); lo_message_pp(msg);}); j*=2; - s.add_method("test12", "i", [j](const lo::Message m) - {printf("test12 (j=%d) source: %s\n", j, m.source().url().c_str());}); + s.add_method("/test12", "i", [j](const lo::Message m) + {printf("/test12 (j=%d) source: %s\n", j, m.source().url().c_str());}); s.add_method(0, 0, [](const char *path, lo_message m){printf("generic: %s ", path); lo_message_pp(m);}); @@ -168,37 +168,38 @@ int main() printf("iface: %s\n", a.iface().c_str()); #endif - a.send_from(st, "test1", "i", 20); - a.send("test2", "i", 40); - a.send("test3", "i", 60); - a.send("test4", "i", 80); - a.send("test5", "i", 100); - a.send("test6", "i", 120); - a.send("test7", "i", 140); - a.send("test8", "i", 160); - a.send("test9", "i", 180); - a.send("test10", std::string("i"), 200); + a.send_from(st, "/test1", "i", 20); + a.send("/test2", "i", 40); + a.send("/test3", "i", 60); + a.send("/test4", "i", 80); + a.send("/test5", "i", 100); + a.send("/test6", "i", 120); + a.send("/test7", "i", 140); + a.send("/test8", "i", 160); + a.send("/test9", "i", 180); + a.send("/test10", std::string("i"), 200); lo::Message m; m.add("i", 220); m.add_string(std::string("blah")); - a.send("test11", m); + a.send("/test11", m); m.add(lo::Blob(4,"asdf")); m.add(lo::Blob(std::vector(5, 'a'))); m.add(lo::Blob(std::array{"asdf"})); - a.send("blobtest", m); + a.send("/blobtest", m); a.send( lo::Bundle({ - {"test11", lo::Message("is",20,"first in bundle")}, - {"test11", lo::Message("is",30,"second in bundle")} - }) - ); - - lo::Bundle b({{"ok1", lo::Message("is",20,"first in bundle")}, - lo::Bundle({"ok2", lo::Message("is",30,"second in bundle")}) - }, LO_TT_IMMEDIATE); + {"/test11", lo::Message("is",20,"first in bundle")}, + {"/test11", lo::Message("is",30,"second in bundle")} + }) + ); + + lo::Bundle b({ + {"/ok1", lo::Message("is",20,"first in bundle")}, + lo::Bundle({"/ok2", lo::Message("is",30,"second in bundle")}) + }, LO_TT_IMMEDIATE); printf("Bundle:\n"); b.print(); lo::Bundle::Element e(b.get_element(0)); @@ -211,7 +212,7 @@ int main() e.bundle.timestamp().sec, e.bundle.timestamp().frac); - a.send("test12", "i", 240); + a.send("/test12", "i", 240); char oscmsg[] = {'/','o','k',0,',','i',0,0,0,0,0,4}; lo::Message::maybe m2 = lo::Message::deserialise(oscmsg, sizeof(oscmsg)); From ba8d166d484f73fd921e927cc154a8770dee6c32 Mon Sep 17 00:00:00 2001 From: Joseph Malloch Date: Wed, 6 Nov 2024 12:13:38 -0400 Subject: [PATCH 2/2] testlo: Try adding a one-second sleep for server_thread to process messages before deleting coerce_handler. --- src/testlo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/testlo.c b/src/testlo.c index 2d6be386..0d9e8aa1 100644 --- a/src/testlo.c +++ b/src/testlo.c @@ -1400,6 +1400,8 @@ void test_server_thread(lo_server_thread *pst, lo_address *pa) -0.00000023001f, 1.0); lo_send(a, "/a/b/c/d", "b", btest); + SLEEP_MS(1000); + /* Delete methods */ lo_server_thread_del_method(st, "/coerce", "dfhiSs"); TEST (lo_server_thread_del_lo_method(st, jit) == 0);