Lines Matching defs:test

41 static int run_test(struct pci_test *test)
47 fd = open(test->device, O_RDWR);
53 if (test->barnum >= 0 && test->barnum <= 5) {
54 ret = ioctl(fd, PCITEST_BAR, test->barnum);
55 fprintf(stdout, "BAR%d:\t\t", test->barnum);
62 if (test->set_irqtype) {
63 ret = ioctl(fd, PCITEST_SET_IRQTYPE, test->irqtype);
64 fprintf(stdout, "SET IRQ TYPE TO %s:\t\t", irq[test->irqtype]);
71 if (test->get_irqtype) {
80 if (test->clear_irq) {
89 if (test->legacyirq) {
98 if (test->msinum > 0 && test->msinum <= 32) {
99 ret = ioctl(fd, PCITEST_MSI, test->msinum);
100 fprintf(stdout, "MSI%d:\t\t", test->msinum);
107 if (test->msixnum > 0 && test->msixnum <= 2048) {
108 ret = ioctl(fd, PCITEST_MSIX, test->msixnum);
109 fprintf(stdout, "MSI-X%d:\t\t", test->msixnum);
116 if (test->write) {
117 param.size = test->size;
118 if (test->use_dma)
121 fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
128 if (test->read) {
129 param.size = test->size;
130 if (test->use_dma)
133 fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
140 if (test->copy) {
141 param.size = test->size;
142 if (test->use_dma)
145 fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
154 return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */
160 struct pci_test *test;
162 test = calloc(1, sizeof(*test));
163 if (!test) {
169 test->barnum = -1;
172 test->size = 0x19000;
175 test->device = "/dev/pci-endpoint-test.0";
180 test->device = optarg;
183 test->barnum = atoi(optarg);
184 if (test->barnum < 0 || test->barnum > 5)
188 test->legacyirq = true;
191 test->msinum = atoi(optarg);
192 if (test->msinum < 1 || test->msinum > 32)
196 test->msixnum = atoi(optarg);
197 if (test->msixnum < 1 || test->msixnum > 2048)
201 test->irqtype = atoi(optarg);
202 if (test->irqtype < 0 || test->irqtype > 2)
204 test->set_irqtype = true;
207 test->get_irqtype = true;
210 test->read = true;
213 test->write = true;
216 test->copy = true;
219 test->clear_irq = true;
222 test->size = strtoul(optarg, NULL, 0);
225 test->use_dma = true;
233 "\t-D <dev> PCI endpoint test device {default: /dev/pci-endpoint-test.0}\n"
234 "\t-b <bar num> BAR test (bar number between 0..5)\n"
235 "\t-m <msi num> MSI test (msi number between 1..32)\n"
236 "\t-x <msix num> \tMSI-X test (msix number between 1..2048)\n"
241 "\t-l Legacy IRQ test\n"
242 "\t-r Read buffer test\n"
243 "\t-w Write buffer test\n"
244 "\t-c Copy buffer test\n"
251 return run_test(test);