1 // Copyright 2017 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <stdio.h>
6 
7 #include <unittest/unittest.h>
8 
9 #if ENABLE_ENTROPY_COLLECTOR_TEST
10 
entropy_file_exists()11 bool entropy_file_exists() {
12     BEGIN_TEST;
13 
14     FILE* file = fopen("/boot/kernel/debug/entropy.bin", "rb");
15     ASSERT_NONNULL(file, "entropy file doesn't exist");
16 
17     char buf[32];
18     size_t read = fread(buf, 1, sizeof(buf), file);
19 
20     EXPECT_LT(0, read, "entropy file contains no data or not readable");
21 
22     END_TEST;
23 }
24 
25 BEGIN_TEST_CASE(entropy_tests)
26 RUN_TEST(entropy_file_exists);
END_TEST_CASE(entropy_tests)27 END_TEST_CASE(entropy_tests)
28 
29 #endif
30 
31 int main(int argc, char** argv) {
32     return unittest_run_all_tests(argc, argv) ? 0 : -1;
33 }
34