pkarashchenko commented on code in PR #1561:
URL: https://github.com/apache/nuttx-apps/pull/1561#discussion_r1113626258


##########
testing/drivertest/drivertest_gpio.c:
##########
@@ -0,0 +1,248 @@
+/****************************************************************************
+ * apps/testing/drivertest/drivertest_gpio.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <nuttx/ioexpander/gpio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+#include <cmocka.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#define GPIOTEST_MAXVALUE 5
+
+struct pre_build_s
+{
+  char *gpio_a;
+  char *gpio_b;
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: show_usage
+ ****************************************************************************/
+
+static void show_usage(FAR const char *progname, int exitcode)
+{
+  printf("Usage: %s -a <gpio_a>[dev/gpio0] -b"
+         " <gpio_b>[dev/gpio1] \n", progname);
+  printf("Where:\n");
+  printf("  -a <gpio_a> gpio_a location [default location: dev/gpio0].\n");
+  printf("  -b <gpio_b> gpio_b location [default location: dev/gpio1].\n");
+  exit(exitcode);
+}
+
+/****************************************************************************
+ * Name: parse_commandline
+ ****************************************************************************/
+
+static void parse_commandline(int argc, FAR char **argv,
+                              FAR struct pre_build_s *pre_build)
+{
+  int option;
+
+  while ((option = getopt(argc, argv, "a:b:")) != ERROR)
+    {
+      switch (option)
+        {
+          case 'a':
+            pre_build->gpio_a = optarg;
+            break;
+          case 'b':
+            pre_build->gpio_b = optarg;
+            break;
+          case '?':
+            printf("Unknown option: %c\n", optopt);
+            show_usage(argv[0], EXIT_FAILURE);
+            break;
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: gpiotest_randbin
+ ****************************************************************************/
+
+static inline bool gpiotest_randbin(void)
+{
+  int value = rand() % 18;
+  if (value > 9)
+    {
+      return true;
+    }
+  else
+    {
+      return false;
+    }
+
+  return true;
+}
+
+/****************************************************************************
+ * Name: setup
+ ****************************************************************************/
+
+static int setup(FAR void **state)
+{
+  FAR struct pre_build_s *pre_build;
+  time_t t;
+  pre_build = (struct pre_build_s *)*state;
+
+  /* Seed the random number generated */
+
+  srand((unsigned)time(&t));
+  *state = pre_build;
+  return 0;
+}
+
+/****************************************************************************
+ * Name: gpiotest01
+ ****************************************************************************/
+
+static void gpiotest01(FAR void **state)
+{
+  FAR struct pre_build_s *pre_build;
+  int fd_a;
+  int fd_b;
+  bool outvalue;
+  bool invalue;
+  int ret;
+  int i;
+
+  pre_build = (struct pre_build_s *)*state;

Review Comment:
   `FAR`



##########
testing/drivertest/drivertest_gpio.c:
##########
@@ -0,0 +1,248 @@
+/****************************************************************************
+ * apps/testing/drivertest/drivertest_gpio.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <nuttx/ioexpander/gpio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+#include <cmocka.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#define GPIOTEST_MAXVALUE 5
+
+struct pre_build_s
+{
+  char *gpio_a;
+  char *gpio_b;

Review Comment:
   add `FAR`



##########
testing/drivertest/drivertest_gpio.c:
##########
@@ -0,0 +1,248 @@
+/****************************************************************************
+ * apps/testing/drivertest/drivertest_gpio.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <nuttx/ioexpander/gpio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdint.h>
+#include <cmocka.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#define GPIOTEST_MAXVALUE 5
+
+struct pre_build_s
+{
+  char *gpio_a;
+  char *gpio_b;
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: show_usage
+ ****************************************************************************/
+
+static void show_usage(FAR const char *progname, int exitcode)
+{
+  printf("Usage: %s -a <gpio_a>[dev/gpio0] -b"
+         " <gpio_b>[dev/gpio1] \n", progname);
+  printf("Where:\n");
+  printf("  -a <gpio_a> gpio_a location [default location: dev/gpio0].\n");
+  printf("  -b <gpio_b> gpio_b location [default location: dev/gpio1].\n");
+  exit(exitcode);
+}
+
+/****************************************************************************
+ * Name: parse_commandline
+ ****************************************************************************/
+
+static void parse_commandline(int argc, FAR char **argv,
+                              FAR struct pre_build_s *pre_build)
+{
+  int option;
+
+  while ((option = getopt(argc, argv, "a:b:")) != ERROR)
+    {
+      switch (option)
+        {
+          case 'a':
+            pre_build->gpio_a = optarg;
+            break;
+          case 'b':
+            pre_build->gpio_b = optarg;
+            break;
+          case '?':
+            printf("Unknown option: %c\n", optopt);
+            show_usage(argv[0], EXIT_FAILURE);
+            break;
+        }
+    }
+}
+
+/****************************************************************************
+ * Name: gpiotest_randbin
+ ****************************************************************************/
+
+static inline bool gpiotest_randbin(void)
+{
+  int value = rand() % 18;
+  if (value > 9)
+    {
+      return true;
+    }
+  else
+    {
+      return false;
+    }
+
+  return true;
+}
+
+/****************************************************************************
+ * Name: setup
+ ****************************************************************************/
+
+static int setup(FAR void **state)
+{
+  FAR struct pre_build_s *pre_build;
+  time_t t;
+  pre_build = (struct pre_build_s *)*state;

Review Comment:
   `FAR`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to