-
Notifications
You must be signed in to change notification settings - Fork 6
/
check_emu.c
63 lines (47 loc) · 979 Bytes
/
check_emu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdlib.h>
#include <check.h>
#include "test.h"
/* Make it harder to forget to add tests to suite. */
#pragma GCC diagnostic error "-Wunused-function"
#define TESTODIR "testoutput/"
static void
setup(void)
{
}
static void
teardown(void)
{
}
START_TEST(test_nop_trace)
{
#define TRACEF "nop3.trace"
FILE *t;
char buf[40];
size_t rd;
int ign;
ign = system("./avr-emu -l 3 -t " TESTODIR TRACEF
" -x testfiles/nop3.bin >/dev/null 2>/dev/null");
(void)ign;
t = fopen(TESTODIR TRACEF, "rb");
ck_assert_ptr_ne(t, NULL);
memset(buf, 0, sizeof(buf));
rd = fread(buf, 1, sizeof(buf) - 1, t);
ck_assert_uint_gt(rd, 0);
ck_assert_str_eq(buf, "0000 \n0000 \n0000 \n");
fclose(t);
#undef TRACEF
}
END_TEST
Suite *
suite_emu(void)
{
Suite *s;
TCase *t;
s = suite_create("emu");
t = tcase_create("trace");
tcase_add_checked_fixture(t, setup, teardown);
tcase_add_test(t, test_nop_trace);
suite_add_tcase(s, t);
return (s);
}