tests: move exported functions below main()
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 23 Feb 2017 14:27:21 +0000 (15:27 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 23 Feb 2017 14:27:21 +0000 (15:27 +0100)
Group all functions that are used exclusively by tests together and
below main() for better readability.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/unit/gpiod-unit.c

index f52505517f0950417ea5a568f11a036a3f2146c1..b6474e4bd7e71d741962272a6f54a7ea6d34deba 100644 (file)
@@ -124,49 +124,6 @@ static void  check_chip_index(unsigned int index)
                die("invalid chip number requested from test code");
 }
 
-const char * gu_chip_path(unsigned int index)
-{
-       check_chip_index(index);
-
-       return globals.test_ctx.chips[index]->path;
-}
-
-const char * gu_chip_name(unsigned int index)
-{
-       check_chip_index(index);
-
-       return globals.test_ctx.chips[index]->name;
-}
-
-unsigned int gu_chip_num(unsigned int index)
-{
-       check_chip_index(index);
-
-       return globals.test_ctx.chips[index]->number;
-}
-
-void _gu_register_test(struct gu_test *test)
-{
-       struct gu_test *tmp;
-
-       if (!globals.test_list_head) {
-               globals.test_list_head = globals.test_list_tail = test;
-               test->_next = NULL;
-       } else {
-               tmp = globals.test_list_tail;
-               globals.test_list_tail = test;
-               test->_next = NULL;
-               tmp->_next = test;
-       }
-
-       globals.num_tests++;
-}
-
-void _gu_set_test_failed(void)
-{
-       globals.test_ctx.test_failed = true;
-}
-
 static bool mockup_loaded(void)
 {
        int state;
@@ -450,3 +407,46 @@ void gu_release_line(struct gpiod_line **line)
        if (*line)
                gpiod_line_release(*line);
 }
+
+const char * gu_chip_path(unsigned int index)
+{
+       check_chip_index(index);
+
+       return globals.test_ctx.chips[index]->path;
+}
+
+const char * gu_chip_name(unsigned int index)
+{
+       check_chip_index(index);
+
+       return globals.test_ctx.chips[index]->name;
+}
+
+unsigned int gu_chip_num(unsigned int index)
+{
+       check_chip_index(index);
+
+       return globals.test_ctx.chips[index]->number;
+}
+
+void _gu_register_test(struct gu_test *test)
+{
+       struct gu_test *tmp;
+
+       if (!globals.test_list_head) {
+               globals.test_list_head = globals.test_list_tail = test;
+               test->_next = NULL;
+       } else {
+               tmp = globals.test_list_tail;
+               globals.test_list_tail = test;
+               test->_next = NULL;
+               tmp->_next = test;
+       }
+
+       globals.num_tests++;
+}
+
+void _gu_set_test_failed(void)
+{
+       globals.test_ctx.test_failed = true;
+}