Loading liblog/tests/libc_test.cpp +19 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <gtest/gtest.h> #include <errno.h> #include <stdio.h> TEST(libc, __pstore_append) { Loading @@ -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" ); } } liblog/tests/liblog_test.cpp +13 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <ctype.h> #include <dirent.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <semaphore.h> Loading Loading @@ -2655,12 +2656,19 @@ TEST(liblog, __android_log_pmsg_file_write) { bool logdwActiveAfter__android_log_close = isLogdwActive(); EXPECT_FALSE(pmsgActiveAfter__android_log_close); EXPECT_FALSE(logdwActiveAfter__android_log_close); EXPECT_LT(0, __android_log_pmsg_file_write( int return__android_log_pmsg_file_write = __android_log_pmsg_file_write( LOG_ID_CRASH, ANDROID_LOG_VERBOSE, __pmsg_file, max_payload_buf, sizeof(max_payload_buf))); __pmsg_file, max_payload_buf, sizeof(max_payload_buf)); EXPECT_LT(0, return__android_log_pmsg_file_write); if (return__android_log_pmsg_file_write == -ENOMEM) { fprintf(stderr, "Kernel does not have space allocated to pmsg pstore driver configured\n" ); } else if (!return__android_log_pmsg_file_write) { fprintf(stderr, "Reboot, ensure file %s matches\n" "with liblog.__android_log_msg_file_read test\n", __pmsg_file); } bool pmsgActiveAfter__android_pmsg_file_write = isPmsgActive(); bool logdwActiveAfter__android_pmsg_file_write = isLogdwActive(); EXPECT_FALSE(pmsgActiveAfter__android_pmsg_file_write); Loading logd/main.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,11 @@ static int drop_privs() { return -1; } if (prctl(PR_SET_DUMPABLE, 0) < 0) { android::prdebug("failed to clear PR_SET_DUMPABLE"); return -1; } gid_t groups[] = { AID_READPROC }; ScopedMinijail j(minijail_new()); minijail_set_supplementary_gids(j.get(), arraysize(groups), groups); Loading Loading
liblog/tests/libc_test.cpp +19 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <gtest/gtest.h> #include <errno.h> #include <stdio.h> TEST(libc, __pstore_append) { Loading @@ -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" ); } }
liblog/tests/liblog_test.cpp +13 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ #include <ctype.h> #include <dirent.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <semaphore.h> Loading Loading @@ -2655,12 +2656,19 @@ TEST(liblog, __android_log_pmsg_file_write) { bool logdwActiveAfter__android_log_close = isLogdwActive(); EXPECT_FALSE(pmsgActiveAfter__android_log_close); EXPECT_FALSE(logdwActiveAfter__android_log_close); EXPECT_LT(0, __android_log_pmsg_file_write( int return__android_log_pmsg_file_write = __android_log_pmsg_file_write( LOG_ID_CRASH, ANDROID_LOG_VERBOSE, __pmsg_file, max_payload_buf, sizeof(max_payload_buf))); __pmsg_file, max_payload_buf, sizeof(max_payload_buf)); EXPECT_LT(0, return__android_log_pmsg_file_write); if (return__android_log_pmsg_file_write == -ENOMEM) { fprintf(stderr, "Kernel does not have space allocated to pmsg pstore driver configured\n" ); } else if (!return__android_log_pmsg_file_write) { fprintf(stderr, "Reboot, ensure file %s matches\n" "with liblog.__android_log_msg_file_read test\n", __pmsg_file); } bool pmsgActiveAfter__android_pmsg_file_write = isPmsgActive(); bool logdwActiveAfter__android_pmsg_file_write = isLogdwActive(); EXPECT_FALSE(pmsgActiveAfter__android_pmsg_file_write); Loading
logd/main.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,11 @@ static int drop_privs() { return -1; } if (prctl(PR_SET_DUMPABLE, 0) < 0) { android::prdebug("failed to clear PR_SET_DUMPABLE"); return -1; } gid_t groups[] = { AID_READPROC }; ScopedMinijail j(minijail_new()); minijail_set_supplementary_gids(j.get(), arraysize(groups), groups); Loading