#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <system_info.h>
#include "peripheral_io.h"
#define KEY_FEATURE_PERIPHERAL_IO_UART "http://tizen.org/feature/peripheral_io.uart"
#define KEY_FEATURE_PERIPHERAL_IO_SPI "http://tizen.org/feature/peripheral_io.spi"
+#define CRED "\x1B[31m"
+#define CGRN "\x1B[32m"
+#define CYEL "\x1B[33m"
+#define RESET "\033[0m"
+
static int fail_count = 0;
static int pass_count = 0;
+static int skip_count = 0;
-static void __error_check(int ret, char *name)
+char *model_name = NULL;
+
+typedef struct
{
- if (ret != PERIPHERAL_ERROR_NONE) {
- printf("[FAIL] %s\n", name);
- fail_count++;
- } else {
- printf("[PASS] %s\n", name);
- pass_count++;
- }
-}
+ const char *test_name, *model_name;
+} skip_test_t;
+
+static skip_test_t skip_test_list[] = {
+ {"test_peripheral_io_spi_peripheral_spi_set_bit_order_p2", "rpi3"}
+};
static int __get_model_name(char **model_name)
{
return PERIPHERAL_ERROR_NONE;
}
+static bool __skip_check(char *name)
+{
+ size_t n = sizeof(skip_test_list) / sizeof(skip_test_list[0]);
+ for (int i = 0; i < n; ++i)
+ if (!strcmp(skip_test_list[i].model_name, model_name) && !strcmp(skip_test_list[i].test_name, name))
+ return true;
+ return false;
+}
+
+static void __error_check(int ret, char *name)
+{
+ if (__skip_check(name)) {
+ printf(CYEL "[SKIP]" RESET " %s\n", name);
+ skip_count++;
+ } else if (ret != PERIPHERAL_ERROR_NONE) {
+ printf(CRED "[FAIL]" RESET " %s\n", name);
+ fail_count++;
+ } else {
+ printf(CGRN "[PASS]" RESET " %s\n", name);
+ pass_count++;
+ }
+}
+
static int __test_peripheral_init(const char *test_name, const char *key_feature, int (*init_fn)(char *, bool))
{
- char *model_name = NULL;
bool feature = false;
int ret;
printf("\n[Message] Initializing %s test\n", test_name);
- ret = __get_model_name(&model_name);
- if (ret != PERIPHERAL_ERROR_NONE) {
- printf("[Message] Failed to get model name: %d\n", ret);
- return ret;
+ if (!model_name) {
+ ret = __get_model_name(&model_name);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ printf("[Message] Failed to get model name: %d\n", ret);
+ return ret;
+ }
}
ret = __get_feature(key_feature, &feature);
if (ret != PERIPHERAL_ERROR_NONE) {
- free(model_name);
printf("[Message] Feature %s not supported\n", key_feature);
return ret;
}
ret = init_fn(model_name, feature);
if (ret != PERIPHERAL_ERROR_NONE) {
- free(model_name);
printf("[Message] Failed to initialize %s test: %d\n", test_name, ret);
return ret;
}
- free(model_name);
return PERIPHERAL_ERROR_NONE;
}
fail_count = 0;
pass_count = 0;
+ skip_count = 0;
switch (menu) {
case 1:
return -1;
}
- printf("\n\nTotal : %d, Pass : %d, Fail : %d\n", pass_count + fail_count, pass_count, fail_count);
+ printf("\n\nTotal : %d, Pass : %d, Fail : %d, Skip : %d\n", pass_count + fail_count + skip_count, pass_count, fail_count, skip_count);
}
+ free(model_name);
+
return -1;
}