From: Waldemar Kozaczuk <[email protected]> Committer: Waldemar Kozaczuk <[email protected]> Branch: master
tests: make tst-string.cc work with glibc The musl version of strsignal() used by OSv returns slightly different message string than glibc. More specifically glibc appends the signal number to the string. We could change musl version to behave exactly like glibc, but instead we tweak the tst-string.cc with ifdef to test correct message version depending how it is compiled. In the end, the test now works on Linux and on OSv with Linux dynamic linker. Signed-off-by: Waldemar Kozaczuk <[email protected]> --- diff --git a/tests/tst-string.cc b/tests/tst-string.cc --- a/tests/tst-string.cc +++ b/tests/tst-string.cc @@ -75,25 +75,43 @@ TEST(STRING_TEST, strsignal) { //ASSERT_STREQ("Real-time signal 14", strsignal(SIGRTMIN + 14)); // Errors. +#ifdef __OSV__ ASSERT_STREQ("Unknown signal", strsignal(-1)); // Too small. ASSERT_STREQ("Unknown signal", strsignal(0)); // Still too small. ASSERT_STREQ("Unknown signal", strsignal(1234)); // Too large. +#else + ASSERT_STREQ("Unknown signal -1", strsignal(-1)); // Too small. + ASSERT_STREQ("Unknown signal 0", strsignal(0)); // Still too small. + ASSERT_STREQ("Unknown signal 1234", strsignal(1234)); // Too large. +#endif } static void* ConcurrentStrSignalFn(void*) { +#ifdef __OSV__ bool equal = (strcmp("Unknown signal", strsignal(2002)) == 0); +#else + bool equal = (strcmp("Unknown signal 2002", strsignal(2002)) == 0); +#endif return reinterpret_cast<void*>(equal); } TEST(STRING_TEST, strsignal_concurrent) { const char* strsignal1001 = strsignal(1001); +#ifdef __OSV__ ASSERT_STREQ("Unknown signal", strsignal1001); +#else + ASSERT_STREQ("Unknown signal 1001", strsignal1001); +#endif pthread_t t; ASSERT_EQ(0, pthread_create(&t, nullptr, ConcurrentStrSignalFn, nullptr)); void* result; ASSERT_EQ(0, pthread_join(t, &result)); ASSERT_TRUE(static_cast<bool>(result)); +#ifdef __OSV__ ASSERT_STREQ("Unknown signal", strsignal1001); +#else + ASSERT_STREQ("Unknown signal 1001", strsignal1001); +#endif } -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/0000000000005458a3060c84e439%40google.com.
