#include <comedilib.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdlib.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <getopt.h>
int test_info(void);
int test_mode0_read(void);
int test_insn_read(void);
+int test_insn_read_0(void);
int test_insn_read_time(void);
int test_cmd_no_cmd(void);
int test_cmd_probe_src_mask(void);
int test_cmd_probe_fast_1chan(void);
int test_cmd_read_fast_1chan(void);
+int test_cmd_write_fast_1chan(void);
int test_cmd_logic_bug(void);
int test_cmd_fifo_depth_check(void);
int test_cmd_start_inttrig(void);
};
struct test_struct tests[]={
{ "info", test_info, TEST_STD },
- { "mode0_read", test_mode0_read, TEST_STD },
+ { "mode0_read", test_mode0_read, TEST_NEVER },
{ "insn_read", test_insn_read, TEST_STD },
+ { "insn_read_0", test_insn_read_0, TEST_STD },
{ "insn_read_time", test_insn_read_time, TEST_STD },
{ "cmd_no_cmd", test_cmd_no_cmd, TEST_STD },
{ "cmd_probe_src_mask", test_cmd_probe_src_mask, TEST_STD },
{ "cmd_probe_fast_1chan", test_cmd_probe_fast_1chan, TEST_STD },
{ "cmd_read_fast_1chan", test_cmd_read_fast_1chan, TEST_STD },
+ { "cmd_write_fast_1chan", test_cmd_write_fast_1chan, TEST_STD },
{ "cmd_logic_bug", test_cmd_logic_bug, TEST_STD },
{ "cmd_fifo_depth_check", test_cmd_fifo_depth_check, TEST_STD },
{ "cmd_start_inttrig", test_cmd_start_inttrig, TEST_STD },
static void get_capabilities(unsigned int subd);
static void print_device_info(void);
+void help(int ret)
+{
+ int i;
+
+ fprintf(stderr,
+"comedi_test [options]\n"
+" --device, -f <device_file> Use device <device_file>\n"
+" --realtime, -r Use real-time interrupts, if available\n"
+" --subdevice, -s <index> Only test subdevice <index>\n"
+" --test, -t <test> Only run test <test>\n"
+" --verbose, -v Be verbose\n"
+" --help, -h Print this message\n"
+"Available tests: ");
+ for(i=0;i<n_tests;i++){
+ fprintf(stderr,"%s ",tests[i].name);
+ }
+ fprintf(stderr,"\n");
+
+ exit(ret);
+}
+
+static struct option longopts[]={
+ { "device", 1, 0, 'f' },
+ { "realtime", 0, 0, 'r' },
+ { "subdevice", 1, 0, 's' },
+ { "test", 1, 0, 't' },
+ { "verbose", 0, 0, 'v' },
+ { "help", 0, 0, 'h' },
+ {0}
+};
+
int main(int argc, char *argv[])
{
int c;
int i;
+ setvbuf(stdout,NULL,_IONBF,0);
+
while (1) {
- c = getopt(argc, argv, "f:rs:t:v");
+ c = getopt_long(argc, argv, "f:rs:t:v", longopts, NULL);
if (c == -1)
break;
switch (c) {
case 't':
only_test = optarg;
break;
+ case 'h':
+ help(0);
+ break;
case 'v':
verbose = 1;
break;
default:
- printf("bad option\n");
- exit(1);
+ help(1);
+ break;
}
}
device = comedi_open(filename);
if(!device){
printf("E: comedi_open(\"%s\"): %s\n",filename,strerror(errno));
- exit(0);
+ exit(1);
}
print_device_info();