Lines Matching defs:unittest
39 #define unittest(result, fmt, ...) ({ \
78 unittest(np && name && !strcmp("/testcase-data", name),
85 unittest(!np, "trailing '/' on /testcase-data/ should fail\n");
89 unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name),
96 unittest(np && name && !strcmp("/testcase-data", name),
103 unittest(!np, "trailing '/' on testcase-alias/ should fail\n");
107 unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name),
113 unittest(!np, "non-existent path returned node %pOF\n", np);
117 unittest(!np, "non-existent alias returned node %pOF\n", np);
121 unittest(!np, "non-existent alias with relative path returned node %pOF\n", np);
125 unittest(np && !strcmp("testoption", options),
130 unittest(np && !strcmp("test/option", options),
135 unittest(np && !strcmp("test/option", options),
140 unittest(np, "NULL option path test failed\n");
145 unittest(np && !strcmp("testaliasoption", options),
151 unittest(np && !strcmp("test/alias/option", options),
156 unittest(np, "NULL option alias path test failed\n");
161 unittest(np && !options, "option clearing test failed\n");
166 unittest(np && !options, "option clearing root node test failed\n");
184 unittest(0, "kzalloc() failed\n");
192 unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");
199 unittest(of_add_property(np, prop) != 0,
205 unittest(of_update_property(np, prop) == 0,
213 unittest(of_update_property(np, prop) == 0,
217 unittest(of_remove_property(np, prop) == 0,
225 unittest(prop->value != NULL, "Unable to allocate large buffer\n");
227 unittest(of_add_property(np, prop) == 0,
268 unittest(child_count > 0, "Device node data structure is corrupted\n");
269 unittest(child_count == allnode_count,
292 unittest((strcmp(buf, expected) == 0) && (buf[size+1] == 0xff),
302 unittest(strncmp(buf, expected, size) == 0 && (buf[size+1] == 0xff),
317 unittest(np, "testcase data missing\n");
377 unittest(dup_count == 0, "Found %i duplicates in %i phandles\n",
400 unittest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc);
454 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
465 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
468 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
482 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
493 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
507 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
518 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
532 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
543 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
574 unittest(rc == 8, "of_count_phandle_with_args() returned %i, expected 8\n", rc);
640 unittest(passed, "index %i - data error on node %s rc=%i\n",
651 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
664 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
677 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
690 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
693 unittest(prefs[i] == OF_KREF_READ(p[i]),
713 unittest(rc == 0, "first expected:0 got:%i\n", rc);
715 unittest(rc == 1, "second expected:1 got:%i\n", rc);
717 unittest(rc == 2, "third expected:2 got:%i\n", rc);
719 unittest(rc == -ENODATA, "unmatched string; rc=%i\n", rc);
721 unittest(rc == -EINVAL, "missing property; rc=%i\n", rc);
723 unittest(rc == -ENODATA, "empty property; rc=%i\n", rc);
725 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
729 unittest(rc == 1, "Incorrect string count; rc=%i\n", rc);
731 unittest(rc == 3, "Incorrect string count; rc=%i\n", rc);
733 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
735 unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
739 unittest(rc == 0 && !strcmp(strings[0], "foobar"), "of_property_read_string_index() failure; rc=%i\n", rc);
742 unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
744 unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
746 unittest(rc == 0 && !strcmp(strings[0], "second"), "of_property_read_string_index() failure; rc=%i\n", rc);
748 unittest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\n", rc);
751 unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
754 unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
756 unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
759 unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
764 unittest(rc == 1, "Incorrect string count; rc=%i\n", rc);
766 unittest(rc == 3, "Incorrect string count; rc=%i\n", rc);
768 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
771 unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
775 unittest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc);
778 unittest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, strings[1]);
793 unittest(new && propcmp(&p1, new), "empty property didn't copy correctly\n");
799 unittest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n");
819 unittest(n1, "testcase setup failure\n");
822 unittest(n2, "testcase setup failure\n");
825 unittest(n21, "testcase setup failure %p\n", n21);
829 unittest(nremove, "testcase setup failure\n");
832 unittest(ppadd, "testcase setup failure\n");
835 unittest(ppname_n1, "testcase setup failure\n");
838 unittest(ppname_n2, "testcase setup failure\n");
841 unittest(ppname_n21, "testcase setup failure\n");
844 unittest(ppupdate, "testcase setup failure\n");
852 unittest(ppremove, "failed to find removal prop");
856 unittest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n");
857 unittest(!of_changeset_add_property(&chgset, n1, ppname_n1), "fail add prop name\n");
859 unittest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n");
860 unittest(!of_changeset_add_property(&chgset, n2, ppname_n2), "fail add prop name\n");
862 unittest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n");
863 unittest(!of_changeset_add_property(&chgset, n21, ppname_n21), "fail add prop name\n");
865 unittest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n");
867 unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop prop-add\n");
868 unittest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n");
869 unittest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n");
871 unittest(!of_changeset_apply(&chgset), "apply failed\n");
876 unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")),
880 unittest(!of_changeset_revert(&chgset), "revert failed\n");
905 unittest(cpu_addr == 0x4fffffff,
926 unittest(!rc, "of_dma_get_range failed on node %pOF rc=%i\n", np, rc);
935 unittest(0, "kzalloc() failed\n");
944 unittest(paddr == expect_paddr,
947 unittest(dma_addr == expect_dma_addr,
995 unittest(range.size == 0x10000000,
998 unittest(range.cpu_addr == 0x20000000,
1001 unittest(range.pci_addr == 0x80000000,
1005 unittest(range.size == 0x10000000,
1008 unittest(range.cpu_addr == 0x40000000,
1011 unittest(range.pci_addr == 0xc0000000,
1046 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
1092 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
1166 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
1216 unittest(0, "missing testcase node %s\n",
1223 unittest(0, "%s didn't match anything\n",
1229 unittest(0, "%s got wrong match. expected %s, got %s\n",
1234 unittest(1, "passed");
1244 .name = "unittest-bus",
1262 unittest(pdev, "device 1 creation failed\n");
1266 unittest(irq == -EPROBE_DEFER,
1272 unittest(pdev, "device 2 creation failed\n");
1282 unittest(irq < 0 && irq != -EPROBE_DEFER,
1287 unittest(np, "No testcase data in device tree\n");
1293 unittest(!rc, "testbus registration failed; rc=%i\n", rc);
1313 unittest(pdev,
1323 unittest(!of_find_device_by_node(grandchild),
1352 * "unittest internal error: unable to add testdata property"
1355 * the respective unittest overlay contains a label that has the
1359 * please consider renaming __all__ of the labels in the unittest
1374 pr_err("unittest internal error: unable to add testdata property %pOF/%s",
1542 { .compatible = "unittest", },
1550 .name = "unittest",
1614 devptr->chip.label = "of-unittest-gpio";
1621 unittest(!ret,
1650 { .compatible = "unittest-gpio", },
1658 .name = "unittest-gpio",
1699 unittest(overlay_data_apply("overlay_gpio_01", NULL),
1702 unittest(overlay_data_apply("overlay_gpio_02a", NULL),
1705 unittest(overlay_data_apply("overlay_gpio_02b", NULL),
1720 if (unittest(ret == 0, "could not register unittest gpio driver\n"))
1728 unittest(probe_pass_count + 2 == unittest_gpio_probe_pass_count,
1731 unittest(chip_request_count + 2 == unittest_gpio_chip_request_count,
1757 unittest(overlay_data_apply("overlay_gpio_03", NULL),
1763 unittest(probe_pass_count + 1 == unittest_gpio_probe_pass_count,
1766 unittest(chip_request_count + 1 == unittest_gpio_chip_request_count,
1784 unittest(overlay_data_apply("overlay_gpio_04a", NULL),
1787 unittest(probe_pass_count + 1 == unittest_gpio_probe_pass_count,
1804 unittest(overlay_data_apply("overlay_gpio_04b", NULL),
1810 unittest(chip_request_count + 1 == unittest_gpio_chip_request_count,
1892 snprintf(buf, sizeof(buf) - 1, "%s/test-unittest%d", base, nr);
2000 unittest(0, "could not apply overlay \"%s\"\n",
2016 /* unittest device must not be in before state */
2018 unittest(0, "%s with device @\"%s\" %s\n",
2028 /* of_unittest_apply_overlay already called unittest() */
2032 /* unittest device must be to set to after state */
2034 unittest(0, "%s failed to create @\"%s\" %s\n",
2051 /* unittest device must be in before state */
2053 unittest(0, "%s with device @\"%s\" %s\n",
2064 /* of_unittest_apply_overlay already called unittest() */
2068 /* unittest device must be in after state */
2070 unittest(0, "%s failed to create @\"%s\" %s\n",
2080 unittest(0, "%s failed to be destroyed @\"%s\"\n",
2087 /* unittest device must be again in before state */
2089 unittest(0, "%s with device @\"%s\" %s\n",
2116 unittest(1, "overlay test %d passed\n", 0);
2136 unittest(1, "overlay test %d passed\n", 1);
2156 unittest(1, "overlay test %d passed\n", 2);
2176 unittest(1, "overlay test %d passed\n", 3);
2186 unittest(1, "overlay test %d passed\n", 4);
2206 unittest(1, "overlay test %d passed\n", 5);
2219 /* unittest device must be in before state */
2223 unittest(0, "%s with device @\"%s\" %s\n",
2242 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2259 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2270 /* unittest device must be in after state */
2273 unittest(0, "overlay @\"%s\" failed @\"%s\" %s\n",
2285 unittest(0, "%s failed destroy @\"%s\"\n",
2295 /* unittest device must be again in before state */
2298 unittest(0, "%s with device @\"%s\" %s\n",
2307 unittest(1, "overlay test %d passed\n", 6);
2328 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2351 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2376 unittest(0, "%s was destroyed @\"%s\"\n",
2387 unittest(0, "%s not destroyed @\"%s\"\n",
2396 unittest(1, "overlay test %d passed\n", 8);
2408 if (unittest(ret == 0,
2414 if (unittest(child_path, "overlay test %d failed; kasprintf\n", 10))
2420 unittest(ret, "overlay test %d failed; no child device\n", 10);
2432 unittest(ret == 0, "overlay test %d failed; overlay apply\n", 11);
2519 { .compatible = "unittest-i2c-bus", },
2527 .name = "unittest-i2c-bus",
2558 { .name = "unittest-i2c-dev" },
2564 .name = "unittest-i2c-dev",
2637 { .name = "unittest-i2c-mux" },
2643 .name = "unittest-i2c-mux",
2657 if (unittest(ret == 0,
2658 "could not register unittest i2c device driver\n"))
2663 if (unittest(ret == 0,
2664 "could not register unittest i2c bus driver\n"))
2677 if (unittest(ret == 0,
2678 "could not register unittest i2c mux driver\n"))
2710 unittest(1, "overlay test %d passed\n", 12);
2730 unittest(1, "overlay test %d passed\n", 13);
2754 unittest(1, "overlay test %d passed\n", 15);
2769 unittest(0, "could not register unittest driver\n");
2775 unittest(0, "could not find bus_path \"%s\"\n", bus_path);
2780 unittest(0, "could not populate bus @ \"%s\"\n", bus_path);
2785 unittest(0, "could not find unittest0 @ \"%s\"\n",
2791 unittest(0, "unittest1 @ \"%s\" should not exist\n",
2796 unittest(1, "basic infrastructure of overlays passed");
2812 if (unittest(of_unittest_overlay_i2c_init() == 0, "i2c init failed\n"))
2936 * Create base device tree for the overlay unittest.
3068 unittest(0, "overlay_base_root not initialized\n");
3118 unittest(0, "illegal node name in overlay_base %pOFn",
3155 unittest(0, "__of_prop_dup() of '%s' from overlay_base node __symbols__",
3166 unittest(0, "duplicate property '%s' in overlay_base node __symbols__",
3171 unittest(0, "unable to add property '%s' in overlay_base node __symbols__ to sysfs",
3231 unittest(ret, "Adding overlay 'overlay' failed\n");
3238 unittest(overlay_data_apply("overlay_bad_add_dup_node", NULL),
3253 unittest(overlay_data_apply("overlay_bad_add_dup_prop", NULL),
3263 unittest(overlay_data_apply("overlay_bad_phandle", NULL),
3266 unittest(overlay_data_apply("overlay_bad_symbol", NULL),
3286 pr_info("start of unittest - you will see error messages\n");
3288 /* adding data for unittest */
3330 pr_info("end of unittest - %i passed, %i failed\n",