test_blackbox.c (841B)
1 #include "tests.h" 2 3 #include <sys/stat.h> 4 #include <stdio.h> 5 6 /* Declare a local suite. */ 7 SUITE(blackbox); 8 9 TEST have_source_file(void) { 10 struct stat sb; 11 int stat_result = stat("json/example1_once.json", &sb); 12 ASSERT_EQ(0, stat_result); 13 PASS(); 14 } 15 16 const char expect_example1_stdout[] = "var1=hello\nvar2=\nvar3=_hello\n"; 17 TEST example1(void) { 18 FILE *stream = popen("./gen-miniroon.py json/example1.json | ../src/build/miniroon-read miniroon", "r"); 19 ASSERT(stream); 20 21 char out[sizeof(expect_example1_stdout)]; 22 size_t read_len = fread(out, sizeof(out), 1, stream); 23 ASSERT_EQ(sizeof(out), read_len); 24 ASSERT_STRN_EQ(expect_example1_stdout, out, sizeof(out)); 25 26 int ret = pclose(stream); 27 ASSERT_EQ(0, ret); 28 29 PASS(); 30 } 31 32 /* Primary test suite. */ 33 SUITE(blackbox) { 34 RUN_TEST(have_source_file); 35 RUN_TEST(example1); 36 }