15 #include "comedi_test.h"
17 char *filename="/dev/comedi0";
27 int test_mode0_read(void);
28 int test_insn_read(void);
29 int test_insn_read_time(void);
30 int test_cmd_no_cmd(void);
31 int test_cmd_probe_src_mask(void);
32 int test_cmd_probe_fast_1chan(void);
33 int test_cmd_read_fast_1chan(void);
34 int test_cmd_logic_bug(void);
35 int test_cmd_fifo_depth_check(void);
36 int test_cmd_start_inttrig(void);
38 int test_read_select(void);
39 int test_cmd_continuous(void);
40 int test_bufconfig(void);
50 struct test_struct tests[]={
51 { "info", test_info, TEST_STD },
52 { "mode0_read", test_mode0_read, TEST_NEVER },
53 { "insn_read", test_insn_read, TEST_STD },
54 { "insn_read_time", test_insn_read_time, TEST_STD },
55 { "cmd_no_cmd", test_cmd_no_cmd, TEST_STD },
56 { "cmd_probe_src_mask", test_cmd_probe_src_mask, TEST_STD },
57 { "cmd_probe_fast_1chan", test_cmd_probe_fast_1chan, TEST_STD },
58 { "cmd_read_fast_1chan", test_cmd_read_fast_1chan, TEST_STD },
59 { "cmd_logic_bug", test_cmd_logic_bug, TEST_STD },
60 { "cmd_fifo_depth_check", test_cmd_fifo_depth_check, TEST_STD },
61 { "cmd_start_inttrig", test_cmd_start_inttrig, TEST_STD },
62 { "mmap", test_mmap, TEST_STD },
63 { "read_select", test_read_select, TEST_STD },
64 { "cmd_continuous", test_cmd_continuous, TEST_NEVER },
65 { "bufconfig", test_bufconfig, TEST_STD },
67 static int n_tests = sizeof(tests)/sizeof(tests[0]);
74 static void get_capabilities(unsigned int subd);
75 static void print_device_info(void);
82 "comedi_test [options]\n"
83 " --device, -f <device_file> Use device <device_file>\n"
84 " --realtime, -r Use real-time interrupts, if available\n"
85 " --subdevice, -s <index> Only test subdevice <index>\n"
86 " --test, -t <test> Only run test <test>\n"
87 " --verbose, -v Be verbose\n"
88 " --help, -h Print this message\n"
90 for(i=0;i<n_tests;i++){
91 fprintf(stderr,"%s ",tests[i].name);
98 static struct option longopts[]={
99 { "device", 1, 0, 'f' },
100 { "realtime", 0, 0, 'r' },
101 { "subdevice", 1, 0, 's' },
102 { "test", 1, 0, 't' },
103 { "verbose", 0, 0, 'v' },
104 { "help", 0, 0, 'h' },
108 int main(int argc, char *argv[])
113 setvbuf(stdout,NULL,_IONBF,0);
116 c = getopt_long(argc, argv, "f:rs:t:v", longopts, NULL);
128 sscanf(optarg,"%d",&subdevice);
145 device = comedi_open(filename);
147 printf("E: comedi_open(\"%s\"): %s\n",filename,strerror(errno));
153 for(;subdevice<comedi_get_n_subdevices(device);subdevice++){
155 printf("I: subdevice %d\n",subdevice);
156 get_capabilities(subdevice);
158 for(i=0;i<n_tests;i++){
159 if(!strcmp(tests[i].name,only_test)){
160 printf("I: testing %s...\n",tests[i].name);
165 for(i=0;i<n_tests;i++){
166 if(tests[i].flags&TEST_STD){
167 printf("I: testing %s...\n",tests[i].name);
172 if(only_subdevice)break;
178 unsigned int capabilities;
180 static void get_capabilities(unsigned int subd)
187 type = comedi_get_subdevice_type(device,subd);
189 flags = comedi_get_subdevice_flags(device,subd);
193 static void print_device_info(void)
195 int vers = comedi_get_version_code(device);
197 printf("I: Comedi version: %d.%d.%d\n",(vers>>16)&0xff,
198 (vers>>8)&0xff,vers&0xff);
199 printf("I: Comedilib version: unknown =)\n");
200 printf("I: driver name: %s\n",comedi_get_driver_name(device));
201 printf("I: device name: %s\n",comedi_get_board_name(device));