diff options
author | Mark Salyzyn <salyzyn@google.com> | 2016-11-03 20:53:08 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-11-03 20:53:09 +0000 |
commit | 11f8b2006827a70faf9eafabdc34b80f8237a855 (patch) | |
tree | 8157056bf5b92a6e0f673d51e41fb7810eb61f69 /liblog/tests/libc_test.cpp | |
parent | 3a724a8f5d7876b97e4e7f39a0cfc2f0fdc87fd3 (diff) | |
parent | 5febc5131899402e983c319af9c38596ee9a56a2 (diff) |
Merge changes Ifb1b550c,Ic7377efc
* changes:
liblog: test report pmsg not configured if ENOMEM return
logd: clear DUMPABLE
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" + ); + } } |