xref: /minix3/minix/tests/kernel/sys_padconf/padconftest.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc /* Test for sys_padconf() */
2*433d6423SLionel Sambuc #include <errno.h>
3*433d6423SLionel Sambuc #include <stdio.h>
4*433d6423SLionel Sambuc #include <minix/com.h>
5*433d6423SLionel Sambuc #include <minix/syslib.h>
6*433d6423SLionel Sambuc #include <minix/padconf.h>
7*433d6423SLionel Sambuc #include <minix/drivers.h>
8*433d6423SLionel Sambuc #include <assert.h>
9*433d6423SLionel Sambuc 
10*433d6423SLionel Sambuc static unsigned int failures = 0;
11*433d6423SLionel Sambuc 
12*433d6423SLionel Sambuc /*
13*433d6423SLionel Sambuc  * padconf is only supported on ARM. On other systems sys_padconf() should
14*433d6423SLionel Sambuc  * return -EBADREQUEST.
15*433d6423SLionel Sambuc  */
test_badrequest(void)16*433d6423SLionel Sambuc static void test_badrequest(void)
17*433d6423SLionel Sambuc {
18*433d6423SLionel Sambuc #if !defined(__arm__)
19*433d6423SLionel Sambuc 	int r;
20*433d6423SLionel Sambuc 
21*433d6423SLionel Sambuc 	r = sys_padconf(0xffffffff, 0xffffffff, 0xffffffff);
22*433d6423SLionel Sambuc 	if (r != -EBADREQUEST) {
23*433d6423SLionel Sambuc 		printf("Expected r=%d | Got r=%d\n", -EBADREQUEST, r);
24*433d6423SLionel Sambuc 		failures++;
25*433d6423SLionel Sambuc 	}
26*433d6423SLionel Sambuc #endif
27*433d6423SLionel Sambuc 	return;
28*433d6423SLionel Sambuc }
29*433d6423SLionel Sambuc 
do_tests(void)30*433d6423SLionel Sambuc static void do_tests(void)
31*433d6423SLionel Sambuc {
32*433d6423SLionel Sambuc 	test_badrequest();
33*433d6423SLionel Sambuc }
34*433d6423SLionel Sambuc 
sef_cb_init_fresh(int UNUSED (type),sef_init_info_t * UNUSED (info))35*433d6423SLionel Sambuc static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
36*433d6423SLionel Sambuc {
37*433d6423SLionel Sambuc 	do_tests();
38*433d6423SLionel Sambuc 
39*433d6423SLionel Sambuc 	/* The returned code will determine the outcome of the RS call, and
40*433d6423SLionel Sambuc 	 * thus the entire test. The actual error code does not matter.
41*433d6423SLionel Sambuc 	 */
42*433d6423SLionel Sambuc 	return (failures) ? EINVAL : 0;
43*433d6423SLionel Sambuc }
44*433d6423SLionel Sambuc 
sef_local_startup(void)45*433d6423SLionel Sambuc static void sef_local_startup(void)
46*433d6423SLionel Sambuc {
47*433d6423SLionel Sambuc 	sef_setcb_init_fresh(sef_cb_init_fresh);
48*433d6423SLionel Sambuc 
49*433d6423SLionel Sambuc 	sef_startup();
50*433d6423SLionel Sambuc }
51*433d6423SLionel Sambuc 
main(int argc,char ** argv)52*433d6423SLionel Sambuc int main(int argc, char **argv)
53*433d6423SLionel Sambuc {
54*433d6423SLionel Sambuc 	env_setargs(argc, argv);
55*433d6423SLionel Sambuc 
56*433d6423SLionel Sambuc 	sef_local_startup();
57*433d6423SLionel Sambuc 
58*433d6423SLionel Sambuc 	return 0;
59*433d6423SLionel Sambuc }
60