summaryrefslogtreecommitdiff
path: root/tests/port/test_strerror_r.c
blob: 40079d85601737b8f6dace44d529326bd3be72fc (plain)
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
#include "port/sys.h"

#undef HAVE_STRERROR_R
#include "port/string.c"	/* for strerror_r */
#undef strerror_r

#include <stdlib.h>		/* for exit, EXIT_SUCCESS, free */
#include <stdio.h>		/* for printf */

int main( void ) {
	int i;
	int res_sys;
	int res_stub;
	char buf_sys[1024];
	char buf_stub[1024];

	/* go through signal numbers (TODO: find out how many of them there are!) */
	for( i = 0; i < 255; i++ ) {
		printf( "%d: ", i );
		errno = 0;
		*buf_sys = '\0';
		res_sys = strerror_r( i, buf_sys, 1024 );
		printf( "sys: %d \"%s\"", res_sys, buf_sys );
		errno = 0;
		*buf_stub = '\0';
		res_stub = wolf_strerror_r( i, buf_stub, 1024 );
		printf( ", stub: %d \"%s\"\n", res_stub, buf_stub );
	}
	exit( EXIT_SUCCESS );
}