Lines Matching defs:unittest

41 #define unittest(result, fmt, ...) ({ \
87 unittest(np && name && !strcmp("/testcase-data", name),
94 unittest(!np, "trailing '/' on /testcase-data/ should fail\n");
98 unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name),
105 unittest(np && name && !strcmp("/testcase-data", name),
112 unittest(!np, "trailing '/' on testcase-alias/ should fail\n");
116 unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name),
122 unittest(!np, "non-existent path returned node %pOF\n", np);
126 unittest(!np, "non-existent alias returned node %pOF\n", np);
130 unittest(!np, "non-existent alias with relative path returned node %pOF\n", np);
134 unittest(np && !strcmp("testoption", options),
139 unittest(np && !strcmp("test/option", options),
144 unittest(np && !strcmp("test/option", options),
149 unittest(np, "NULL option path test failed\n");
154 unittest(np && !strcmp("testaliasoption", options),
160 unittest(np && !strcmp("test/alias/option", options),
165 unittest(np, "NULL option alias path test failed\n");
170 unittest(np && !options, "option clearing test failed\n");
175 unittest(np && !options, "option clearing root node test failed\n");
193 unittest(0, "kzalloc() failed\n");
201 unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");
208 unittest(of_add_property(np, prop) != 0,
214 unittest(of_update_property(np, prop) == 0,
222 unittest(of_update_property(np, prop) == 0,
226 unittest(of_remove_property(np, prop) == 0,
234 unittest(prop->value != NULL, "Unable to allocate large buffer\n");
236 unittest(of_add_property(np, prop) == 0,
277 unittest(child_count > 0, "Device node data structure is corrupted\n");
278 unittest(child_count == allnode_count,
301 unittest((strcmp(buf, expected) == 0) && (buf[size+1] == 0xff),
311 unittest(strncmp(buf, expected, size) == 0 && (buf[size+1] == 0xff),
326 unittest(np, "testcase data missing\n");
386 unittest(dup_count == 0, "Found %i duplicates in %i phandles\n",
409 unittest(rc == 7, "of_count_phandle_with_args() returned %i, expected 7\n", rc);
463 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
474 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
477 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
491 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
502 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
516 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
527 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
541 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
552 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
583 unittest(rc == 8, "of_count_phandle_with_args() returned %i, expected 8\n", rc);
649 unittest(passed, "index %i - data error on node %s rc=%i\n",
660 unittest(rc == -ENOENT, "expected:%i got:%i\n", -ENOENT, rc);
673 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
686 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
699 unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
702 unittest(prefs[i] == OF_KREF_READ(p[i]),
722 unittest(rc == 0, "first expected:0 got:%i\n", rc);
724 unittest(rc == 1, "second expected:1 got:%i\n", rc);
726 unittest(rc == 2, "third expected:2 got:%i\n", rc);
728 unittest(rc == -ENODATA, "unmatched string; rc=%i\n", rc);
730 unittest(rc == -EINVAL, "missing property; rc=%i\n", rc);
732 unittest(rc == -ENODATA, "empty property; rc=%i\n", rc);
734 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
738 unittest(rc == 1, "Incorrect string count; rc=%i\n", rc);
740 unittest(rc == 3, "Incorrect string count; rc=%i\n", rc);
742 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
744 unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
748 unittest(rc == 0 && !strcmp(strings[0], "foobar"), "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);
753 unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
755 unittest(rc == 0 && !strcmp(strings[0], "second"), "of_property_read_string_index() failure; rc=%i\n", rc);
757 unittest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\n", rc);
760 unittest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
763 unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
765 unittest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
768 unittest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
773 unittest(rc == 1, "Incorrect string count; rc=%i\n", rc);
775 unittest(rc == 3, "Incorrect string count; rc=%i\n", rc);
777 unittest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
780 unittest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
784 unittest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc);
787 unittest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, strings[1]);
802 unittest(new && propcmp(&p1, new), "empty property didn't copy correctly\n");
808 unittest(new && propcmp(&p2, new), "non-empty property didn't copy correctly\n");
832 unittest(n1, "testcase setup failure\n");
835 unittest(n2, "testcase setup failure\n");
838 unittest(n21, "testcase setup failure %p\n", n21);
842 unittest(nremove, "testcase setup failure\n");
845 unittest(ppadd, "testcase setup failure\n");
848 unittest(ppname_n1, "testcase setup failure\n");
851 unittest(ppname_n2, "testcase setup failure\n");
854 unittest(ppname_n21, "testcase setup failure\n");
857 unittest(ppupdate, "testcase setup failure\n");
865 unittest(ppremove, "failed to find removal prop");
869 unittest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n");
870 unittest(!of_changeset_add_property(&chgset, n1, ppname_n1), "fail add prop name\n");
872 unittest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n");
873 unittest(!of_changeset_add_property(&chgset, n2, ppname_n2), "fail add prop name\n");
875 unittest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n");
876 unittest(!of_changeset_add_property(&chgset, n21, ppname_n21), "fail add prop name\n");
878 unittest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n");
880 unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop prop-add\n");
881 unittest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n");
882 unittest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n");
884 unittest(n22, "fail create n22\n");
885 unittest(!of_changeset_add_prop_string(&chgset, n22, "prop-str", "abcd"),
887 unittest(!of_changeset_add_prop_string_array(&chgset, n22, "prop-str-array",
891 unittest(!of_changeset_add_prop_u32_array(&chgset, n22, "prop-u32-array",
895 unittest(!of_changeset_apply(&chgset), "apply failed\n");
900 unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")),
903 unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n22")),
907 unittest(!of_changeset_revert(&chgset), "revert failed\n");
909 unittest(!of_find_node_by_path("/testcase-data/changeset/n2/n21"),
913 unittest(ppremove, "failed to find removed prop after revert\n");
916 unittest(!ret, "failed to find updated prop after revert\n");
918 unittest(strcmp(propstr, "hello") == 0, "original value not in updated property after revert");
944 unittest(cpu_addr == 0x4fffffff,
965 unittest(!rc, "of_dma_get_range failed on node %pOF rc=%i\n", np, rc);
974 unittest(0, "kzalloc() failed\n");
983 unittest(paddr == expect_paddr,
986 unittest(dma_addr == expect_dma_addr,
1034 unittest(range.size == 0x10000000,
1037 unittest(range.cpu_addr == 0x20000000,
1040 unittest(range.pci_addr == 0x80000000,
1044 unittest(range.size == 0x10000000,
1047 unittest(range.cpu_addr == 0x40000000,
1050 unittest(range.pci_addr == 0xc0000000,
1080 unittest(!ret, "of_range_to_resource returned error (%d) node %pOF\n",
1082 unittest(resource_type(&res) == IORESOURCE_MEM,
1085 unittest(res.start == 0xd0000000,
1088 unittest(resource_size(&res) == 0x20000000,
1093 unittest(count == 2,
1101 unittest(range.flags == IORESOURCE_MEM,
1105 unittest(range.size == 0x50000000,
1108 unittest(range.cpu_addr == 0x70000000,
1111 unittest(range.bus_addr == 0x70000000,
1115 unittest(range.size == 0x20000000,
1118 unittest(range.cpu_addr == 0xd0000000,
1121 unittest(range.bus_addr == 0x00000000,
1154 unittest(range.flags == 0xf00baa,
1157 unittest(range.size == 0x100000,
1160 unittest(range.cpu_addr == 0xa0000000,
1163 unittest(range.bus_addr == 0x0,
1167 unittest(range.flags == 0xf00bee,
1170 unittest(range.size == 0x200000,
1173 unittest(range.cpu_addr == 0xb0000000,
1176 unittest(range.bus_addr == 0x100000000,
1199 unittest(!ret, "of_property_read_reg(%pOF) returned error %d\n",
1201 unittest(addr == 0x1000, "of_property_read_reg(%pOF) untranslated address (%llx) incorrect\n",
1232 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
1278 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
1347 * drivers/of/unittest-data/tests-interrupts.dtsi
1358 unittest(passed, "index %i - data error on node %pOF rc=%i\n",
1408 unittest(0, "missing testcase node %s\n",
1415 unittest(0, "%s didn't match anything\n",
1421 unittest(0, "%s got wrong match. expected %s, got %s\n",
1426 unittest(1, "passed");
1432 .name = "unittest-bus",
1450 unittest(pdev, "device 1 creation failed\n");
1454 unittest(irq == -EPROBE_DEFER,
1460 unittest(pdev, "device 2 creation failed\n");
1470 unittest(irq < 0 && irq != -EPROBE_DEFER,
1475 unittest(np, "No testcase data in device tree\n");
1481 unittest(!rc, "testbus registration failed; rc=%i\n", rc);
1501 unittest(pdev,
1511 unittest(!of_find_device_by_node(grandchild),
1540 * "unittest internal error: unable to add testdata property"
1543 * the respective unittest overlay contains a label that has the
1547 * please consider renaming __all__ of the labels in the unittest
1562 pr_err("unittest internal error: unable to add testdata property %pOF/%s",
1739 { .compatible = "unittest", },
1747 .name = "unittest",
1811 devptr->chip.label = "of-unittest-gpio";
1818 unittest(!ret,
1840 { .compatible = "unittest-gpio", },
1848 .name = "unittest-gpio",
1889 unittest(overlay_data_apply("overlay_gpio_01", NULL),
1892 unittest(overlay_data_apply("overlay_gpio_02a", NULL),
1895 unittest(overlay_data_apply("overlay_gpio_02b", NULL),
1899 if (unittest(ret == 0, "could not register unittest gpio driver\n"))
1902 unittest(probe_pass_count + 2 == unittest_gpio_probe_pass_count,
1905 unittest(chip_request_count + 2 == unittest_gpio_chip_request_count,
1928 unittest(overlay_data_apply("overlay_gpio_03", NULL),
1931 unittest(probe_pass_count + 1 == unittest_gpio_probe_pass_count,
1934 unittest(chip_request_count + 1 == unittest_gpio_chip_request_count,
1952 unittest(overlay_data_apply("overlay_gpio_04a", NULL),
1955 unittest(probe_pass_count + 1 == unittest_gpio_probe_pass_count,
1969 unittest(overlay_data_apply("overlay_gpio_04b", NULL),
1972 unittest(chip_request_count + 1 == unittest_gpio_chip_request_count,
2054 snprintf(buf, sizeof(buf) - 1, "%s/test-unittest%d", base, nr);
2147 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2161 /* unittest device must be in before state */
2163 unittest(0, "%s with device @\"%s\" %s\n",
2174 /* of_unittest_apply_overlay already called unittest() */
2178 /* unittest device must be in after state */
2180 unittest(0, "%s with device @\"%s\" %s\n",
2219 unittest(0, "%s failed to be destroyed @\"%s\"\n",
2226 /* unittest device must be again in before state */
2228 unittest(0, "%s with device @\"%s\" %s\n",
2255 unittest(1, "overlay test %d passed\n", 0);
2275 unittest(1, "overlay test %d passed\n", 1);
2295 unittest(1, "overlay test %d passed\n", 2);
2315 unittest(1, "overlay test %d passed\n", 3);
2325 unittest(1, "overlay test %d passed\n", 4);
2345 unittest(1, "overlay test %d passed\n", 5);
2358 /* unittest device must be in before state */
2362 unittest(0, "%s with device @\"%s\" %s\n",
2381 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2398 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2409 /* unittest device must be in after state */
2412 unittest(0, "overlay @\"%s\" failed @\"%s\" %s\n",
2424 unittest(0, "%s failed destroy @\"%s\"\n",
2434 /* unittest device must be again in before state */
2437 unittest(0, "%s with device @\"%s\" %s\n",
2446 unittest(1, "overlay test %d passed\n", 6);
2467 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2490 unittest(0, "could not apply overlay \"%s\"\n", overlay_name);
2519 unittest(0, "%s was destroyed @\"%s\"\n",
2530 unittest(0, "%s not destroyed @\"%s\"\n",
2539 unittest(1, "overlay test %d passed\n", 8);
2551 if (unittest(ret == 0,
2557 if (unittest(child_path, "overlay test %d failed; kasprintf\n", 10))
2563 unittest(ret, "overlay test %d failed; no child device\n", 10);
2575 unittest(ret == 0, "overlay test %d failed; overlay apply\n", 11);
2660 { .compatible = "unittest-i2c-bus", },
2668 .name = "unittest-i2c-bus",
2697 { .name = "unittest-i2c-dev" },
2703 .name = "unittest-i2c-dev",
2774 { .name = "unittest-i2c-mux" },
2780 .name = "unittest-i2c-mux",
2794 if (unittest(ret == 0,
2795 "could not register unittest i2c device driver\n"))
2800 if (unittest(ret == 0,
2801 "could not register unittest i2c bus driver\n"))
2814 if (unittest(ret == 0,
2815 "could not register unittest i2c mux driver\n"))
2847 unittest(1, "overlay test %d passed\n", 12);
2867 unittest(1, "overlay test %d passed\n", 13);
2891 unittest(1, "overlay test %d passed\n", 15);
2979 unittest(!ret,
3000 unittest(overlay_data_apply("overlay_16", &ovcs_id),
3005 unittest(ovcs_id, "ovcs_id not created for overlay_16\n");
3011 unittest(overlay_data_apply("overlay_17", &ovcs_id),
3016 unittest(ovcs_id, "ovcs_id not created for overlay_17\n");
3020 unittest(overlay_data_apply("overlay_18", &ovcs_id),
3023 unittest(ovcs_id, "ovcs_id not created for overlay_18\n");
3034 unittest(1, "overlay_18 of_overlay_remove() injected error for OF_OVERLAY_PRE_REMOVE\n");
3036 unittest(0, "overlay_18 of_overlay_remove() injected error for OF_OVERLAY_PRE_REMOVE not returned\n");
3039 unittest(1, "ovcs_id not created for overlay_18\n");
3042 unittest(ovcs_id, "ovcs_id removed for overlay_18\n");
3046 unittest(overlay_data_apply("overlay_19", &ovcs_id),
3049 unittest(ovcs_id, "ovcs_id not created for overlay_19\n");
3056 unittest(1, "overlay_19 of_overlay_remove() injected error for OF_OVERLAY_POST_REMOVE\n");
3058 unittest(0, "overlay_19 of_overlay_remove() injected error for OF_OVERLAY_POST_REMOVE not returned\n");
3060 unittest(1, "ovcs_id removed for overlay_19\n");
3063 unittest(!ovcs_id, "changeset ovcs_id = %d not removed for overlay_19\n",
3068 unittest(overlay_data_apply("overlay_20", &ovcs_id),
3074 unittest(1, "overlay_20 failed to be destroyed, ret = %d\n",
3077 unittest(1, "ovcs_id not created for overlay_20\n");
3080 unittest(!of_overlay_notifier_unregister(&of_nb),
3090 unittest(0, "could not register unittest driver\n");
3096 unittest(0, "could not find bus_path \"%s\"\n", bus_path);
3101 unittest(0, "could not populate bus @ \"%s\"\n", bus_path);
3106 unittest(0, "could not find unittest0 @ \"%s\"\n",
3112 unittest(0, "unittest1 @ \"%s\" should not exist\n",
3117 unittest(1, "basic infrastructure of overlays passed");
3134 if (unittest(of_unittest_overlay_i2c_init() == 0, "i2c init failed\n"))
3182 unittest(np, "find refcount_path \"%s\"\n", refcount_path);
3189 unittest(0, "guardrail to avoid infinite loop\n");
3207 unittest(1, "/testcase-data/refcount-node is one");
3227 unittest(1, "/testcase-data/refcount-node is zero");
3244 unittest(1, "/testcase-data/refcount-node is zero, second time");
3270 unittest(np, "find refcount_parent_path \"%s\"\n", refcount_parent_path);
3271 unittest(np, "ERROR: devicetree live tree left in a 'bad state' if test fail\n");
3293 unittest(0, "One or more lifecycle tests skipped\n");
3413 * Create base device tree for the overlay unittest.
3560 unittest(0, "overlay_base_root not initialized\n");
3610 unittest(0, "illegal node name in overlay_base %pOFn",
3649 unittest(0, "__of_prop_dup() of '%s' from overlay_base node __symbols__",
3660 unittest(0, "duplicate property '%s' in overlay_base node __symbols__",
3665 unittest(0, "unable to add property '%s' in overlay_base node __symbols__ to sysfs",
3727 unittest(ret, "Adding overlay 'overlay' failed\n");
3740 unittest(overlay_data_apply("overlay_bad_add_dup_node", NULL),
3765 unittest(overlay_data_apply("overlay_bad_add_dup_prop", NULL),
3781 unittest(overlay_data_apply("overlay_bad_phandle", NULL),
3791 unittest(overlay_data_apply("overlay_bad_symbol", NULL),
3806 unittest(overlay_data_apply("overlay_bad_unresolved", NULL),
3899 unittest(res->start == exp_addr, "Incorrect translated address %llx, expected %llx\n",
3908 { .compatible = "unittest-pci" },
3915 .name = "unittest-pci",
3929 unittest(pnp, "Failed creating PCI dt node\n");
3934 path = kasprintf(GFP_KERNEL, "%pOF/pci-ep-bus@0/unittest-pci@100", pnp);
3936 unittest(np, "Failed to get unittest-pci node under PCI node\n");
3943 unittest(reg, "Failed to get reg property\n");
3949 unittest(!np, "Child device tree node is not removed\n");
3951 unittest(!child_dev, "Child device is not removed\n");
3971 unittest(!rc, "Failed to register pci test driver; rc = %d\n", rc);
3976 if (unittest(!rc, "Failed to register unittest pci driver\n")) {
3988 unittest(of_unittest_pci_dev_num,
3990 unittest(of_unittest_pci_dev_num == of_unittest_pci_child_num,
4014 pr_info("start of unittest - you will see error messages\n");
4019 /* adding data for unittest */
4066 pr_info("end of unittest - %i passed, %i failed\n",