diff options
Diffstat (limited to 'liblog/tests/libc_test.cpp')
-rw-r--r-- | liblog/tests/libc_test.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/liblog/tests/libc_test.cpp b/liblog/tests/libc_test.cpp index 3d58147541..f05a955e76 100644 --- a/liblog/tests/libc_test.cpp +++ b/liblog/tests/libc_test.cpp @@ -16,6 +16,7 @@ #include <gtest/gtest.h> +#include <errno.h> #include <stdio.h> TEST(libc, __pstore_append) { @@ -23,6 +24,22 @@ TEST(libc, __pstore_append) { ASSERT_TRUE(NULL != (fp = fopen("/dev/pmsg0", "a"))); static const char message[] = "libc.__pstore_append\n"; ASSERT_EQ((size_t)1, fwrite(message, sizeof(message), 1, fp)); - ASSERT_EQ(0, fclose(fp)); - fprintf(stderr, "Reboot, ensure string libc.__pstore_append is in /sys/fs/pstore/pmsg-ramoops-0\n"); + int fflushReturn = fflush(fp); + int fflushErrno = fflushReturn ? errno : 0; + ASSERT_EQ(0, fflushReturn); + ASSERT_EQ(0, fflushErrno); + int fcloseReturn = fclose(fp); + int fcloseErrno = fcloseReturn ? errno : 0; + ASSERT_EQ(0, fcloseReturn); + ASSERT_EQ(0, fcloseErrno); + if ((fcloseErrno == ENOMEM) || (fflushErrno == ENOMEM)) { + fprintf(stderr, + "Kernel does not have space allocated to pmsg pstore driver configured\n" + ); + } + if (!fcloseReturn && !fcloseErrno && !fflushReturn && !fflushReturn) { + fprintf(stderr, + "Reboot, ensure string libc.__pstore_append is in /sys/fs/pstore/pmsg-ramoops-0\n" + ); + } } |