2016-11-13 12:37:22 +00:00
|
|
|
#include "test.h"
|
|
|
|
|
2016-11-16 19:50:14 +00:00
|
|
|
/* No CRT in this file (this includes stdio and stdlib!). */
|
|
|
|
|
2016-11-13 12:37:22 +00:00
|
|
|
void finished(void)
|
|
|
|
{
|
|
|
|
static const char s[] = "@@FINISHED\n";
|
2017-12-19 02:17:42 +00:00
|
|
|
write(1, s, sizeof(s)-1);
|
2016-11-26 10:56:17 +00:00
|
|
|
_exit(0);
|
2016-11-13 12:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void writehex(uint32_t code)
|
|
|
|
{
|
|
|
|
char buf[8];
|
2016-11-16 19:50:14 +00:00
|
|
|
char* p = &buf[sizeof(buf)];
|
2016-11-13 12:37:22 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2017-12-19 02:17:42 +00:00
|
|
|
*--p = "0123456789abcdef"[(unsigned int)code & 0xf];
|
2016-11-13 12:37:22 +00:00
|
|
|
code >>= 4;
|
|
|
|
}
|
|
|
|
while (code > 0);
|
|
|
|
|
2016-11-16 19:50:14 +00:00
|
|
|
write(1, p, buf + sizeof(buf) - p);
|
2016-11-13 12:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void fail(uint32_t code)
|
|
|
|
{
|
2016-12-01 22:03:30 +00:00
|
|
|
static const char fail_msg[] = "@@FAIL 0x";
|
|
|
|
static const char nl_msg[] = "\n";
|
|
|
|
|
|
|
|
write(1, fail_msg, sizeof(fail_msg)-1);
|
2016-11-13 12:37:22 +00:00
|
|
|
writehex(code);
|
2016-12-01 22:03:30 +00:00
|
|
|
write(1, nl_msg, sizeof(nl_msg)-1);
|
2016-11-13 12:37:22 +00:00
|
|
|
}
|