tests: gpioget: make test cases work with linux v5.1
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 12 Apr 2019 14:37:52 +0000 (16:37 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 23 Apr 2019 09:50:01 +0000 (11:50 +0200)
Make all gpioget test cases work with the recent changes to gpio-mockup
introduced in linux v5.1.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
tests/tests-gpioget.c

index 2c9bcb156982f700f7cf80d6f48634f6e2356dbd..91796ac7ad77c6eddaddca51a7709face48672a6 100644 (file)
@@ -3,6 +3,7 @@
  * This file is part of libgpiod.
  *
  * Copyright (C) 2017-2018 Bartosz Golaszewski <bartekgola@gmail.com>
+ * Copyright (C) 2019 Bartosz Golaszewski <bgolaszewski@baylibre.com>
  */
 
 /* Test cases for the gpioget program. */
 
 static void gpioget_read_all_lines(void)
 {
-       unsigned int offsets[4];
-       int rv, values[4];
-
-       test_tool_run("gpioget", test_chip_name(1),
-                     "0", "1", "2", "3", "4", "5", "6", "7", (char *)NULL);
-       test_tool_wait();
-
-       TEST_ASSERT(test_tool_exited());
-       TEST_ASSERT_RET_OK(test_tool_exit_status());
-       TEST_ASSERT_NOT_NULL(test_tool_stdout());
-       TEST_ASSERT_NULL(test_tool_stderr());
-       TEST_ASSERT_STR_EQ(test_tool_stdout(), "0 0 0 0 0 0 0 0\n");
-
-       offsets[0] = 2;
-       offsets[1] = 3;
-       offsets[2] = 5;
-       offsets[3] = 7;
-
-       values[0] = values[1] = values[2] = values[3] = 1;
-
-       rv = gpiod_ctxless_set_value_multiple(test_chip_name(1), offsets,
-                                             values, 4, false, TEST_CONSUMER,
-                                             NULL, NULL);
-       TEST_ASSERT_RET_OK(rv);
+       test_debugfs_set_value(1, 2, 1);
+       test_debugfs_set_value(1, 3, 1);
+       test_debugfs_set_value(1, 5, 1);
+       test_debugfs_set_value(1, 7, 1);
 
        test_tool_run("gpioget", test_chip_name(1),
                      "0", "1", "2", "3", "4", "5", "6", "7", (char *)NULL);
@@ -52,30 +33,10 @@ TEST_DEFINE(gpioget_read_all_lines,
 
 static void gpioget_read_all_lines_active_low(void)
 {
-       unsigned int offsets[4];
-       int rv, values[4];
-
-       test_tool_run("gpioget", "--active-low", test_chip_name(1),
-                     "0", "1", "2", "3", "4", "5", "6", "7", (char *)NULL);
-       test_tool_wait();
-
-       TEST_ASSERT(test_tool_exited());
-       TEST_ASSERT_RET_OK(test_tool_exit_status());
-       TEST_ASSERT_NOT_NULL(test_tool_stdout());
-       TEST_ASSERT_NULL(test_tool_stderr());
-       TEST_ASSERT_STR_EQ(test_tool_stdout(), "1 1 1 1 1 1 1 1\n");
-
-       offsets[0] = 2;
-       offsets[1] = 3;
-       offsets[2] = 5;
-       offsets[3] = 7;
-
-       values[0] = values[1] = values[2] = values[3] = 1;
-
-       rv = gpiod_ctxless_set_value_multiple(test_chip_name(1), offsets,
-                                             values, 4, false, TEST_CONSUMER,
-                                             NULL, NULL);
-       TEST_ASSERT_RET_OK(rv);
+       test_debugfs_set_value(1, 2, 1);
+       test_debugfs_set_value(1, 3, 1);
+       test_debugfs_set_value(1, 5, 1);
+       test_debugfs_set_value(1, 7, 1);
 
        test_tool_run("gpioget", "--active-low", test_chip_name(1),
                      "0", "1", "2", "3", "4", "5", "6", "7", (char *)NULL);
@@ -93,29 +54,9 @@ TEST_DEFINE(gpioget_read_all_lines_active_low,
 
 static void gpioget_read_some_lines(void)
 {
-       unsigned int offsets[3];
-       int rv, values[3];
-
-       test_tool_run("gpioget", test_chip_name(1),
-                     "0", "1", "4", "6", (char *)NULL);
-       test_tool_wait();
-
-       TEST_ASSERT(test_tool_exited());
-       TEST_ASSERT_RET_OK(test_tool_exit_status());
-       TEST_ASSERT_NOT_NULL(test_tool_stdout());
-       TEST_ASSERT_NULL(test_tool_stderr());
-       TEST_ASSERT_STR_EQ(test_tool_stdout(), "0 0 0 0\n");
-
-       offsets[0] = 1;
-       offsets[1] = 4;
-       offsets[2] = 6;
-
-       values[0] = values[1] = values[2] = 1;
-
-       rv = gpiod_ctxless_set_value_multiple(test_chip_name(1), offsets,
-                                             values, 3, false, TEST_CONSUMER,
-                                             NULL, NULL);
-       TEST_ASSERT_RET_OK(rv);
+       test_debugfs_set_value(1, 1, 1);
+       test_debugfs_set_value(1, 4, 1);
+       test_debugfs_set_value(1, 6, 1);
 
        test_tool_run("gpioget", test_chip_name(1),
                              "0", "1", "4", "6", (char *)NULL);