16 #include "comedi_test.h"
18 char *filename="/dev/comedi0";
28 int test_mode0_read(void);
29 int test_insn_read(void);
30 int test_insn_read_0(void);
31 int test_insn_read_time(void);
32 int test_cmd_no_cmd(void);
33 int test_cmd_probe_src_mask(void);
34 int test_cmd_probe_fast_1chan(void);
35 int test_cmd_read_fast_1chan(void);
36 int test_cmd_write_fast_1chan(void);
37 int test_cmd_logic_bug(void);
38 int test_cmd_fifo_depth_check(void);
39 int test_cmd_start_inttrig(void);
41 int test_read_select(void);
42 int test_cmd_continuous(void);
43 int test_bufconfig(void);
53 struct test_struct tests[]={
54 { "info", test_info, TEST_STD },
55 { "mode0_read", test_mode0_read, TEST_NEVER },
56 { "insn_read", test_insn_read, TEST_STD },
57 { "insn_read_0", test_insn_read_0, TEST_STD },
58 { "insn_read_time", test_insn_read_time, TEST_STD },
59 { "cmd_no_cmd", test_cmd_no_cmd, TEST_STD },
60 { "cmd_probe_src_mask", test_cmd_probe_src_mask, TEST_STD },
61 { "cmd_probe_fast_1chan", test_cmd_probe_fast_1chan, TEST_STD },
62 { "cmd_read_fast_1chan", test_cmd_read_fast_1chan, TEST_STD },
63 { "cmd_write_fast_1chan", test_cmd_write_fast_1chan, TEST_STD },
64 { "cmd_logic_bug", test_cmd_logic_bug, TEST_STD },
65 { "cmd_fifo_depth_check", test_cmd_fifo_depth_check, TEST_STD },
66 { "cmd_start_inttrig", test_cmd_start_inttrig, TEST_STD },
67 { "mmap", test_mmap, TEST_STD },
68 { "read_select", test_read_select, TEST_STD },
69 { "cmd_continuous", test_cmd_continuous, TEST_NEVER },
70 { "bufconfig", test_bufconfig, TEST_STD },
72 static int n_tests = sizeof(tests)/sizeof(tests[0]);
79 static void get_capabilities(unsigned int subd);
80 static void print_device_info(void);
87 "comedi_test [options]\n"
88 " --device, -f <device_file> Use device <device_file>\n"
89 " --realtime, -r Use real-time interrupts, if available\n"
90 " --subdevice, -s <index> Only test subdevice <index>\n"
91 " --test, -t <test> Only run test <test>\n"
92 " --verbose, -v Be verbose\n"
93 " --help, -h Print this message\n"
95 for(i=0;i<n_tests;i++){
96 fprintf(stderr,"%s ",tests[i].name);
103 static struct option longopts[]={
104 { "device", 1, 0, 'f' },
105 { "realtime", 0, 0, 'r' },
106 { "subdevice", 1, 0, 's' },
107 { "test", 1, 0, 't' },
108 { "verbose", 0, 0, 'v' },
109 { "help", 0, 0, 'h' },
113 int main(int argc, char *argv[])
118 setvbuf(stdout,NULL,_IONBF,0);
121 c = getopt_long(argc, argv, "f:rs:t:v", longopts, NULL);
133 sscanf(optarg,"%d",&subdevice);
150 device = comedi_open(filename);
152 printf("E: comedi_open(\"%s\"): %s\n",filename,strerror(errno));
158 for(;subdevice<comedi_get_n_subdevices(device);subdevice++){
160 printf("I: subdevice %d\n",subdevice);
161 get_capabilities(subdevice);
163 for(i=0;i<n_tests;i++){
164 if(!strcmp(tests[i].name,only_test)){
165 printf("I: testing %s...\n",tests[i].name);
170 for(i=0;i<n_tests;i++){
171 if(tests[i].flags&TEST_STD){
172 printf("I: testing %s...\n",tests[i].name);
177 if(only_subdevice)break;
183 unsigned int capabilities;
185 static void get_capabilities(unsigned int subd)
192 type = comedi_get_subdevice_type(device,subd);
194 flags = comedi_get_subdevice_flags(device,subd);
198 static void print_device_info(void)
200 int vers = comedi_get_version_code(device);
202 printf("I: Comedi version: %d.%d.%d\n",(vers>>16)&0xff,
203 (vers>>8)&0xff,vers&0xff);
204 printf("I: Comedilib version: unknown =)\n");
205 printf("I: driver name: %s\n",comedi_get_driver_name(device));
206 printf("I: device name: %s\n",comedi_get_board_name(device));