From 3b7a26fa3e59c0a2872f869c93af8ce61f61ecda Mon Sep 17 00:00:00 2001
From: sheinz <shein@bk.ru>
Date: Tue, 25 Oct 2016 17:52:15 +0300
Subject: [PATCH] Code clean-up

---
 tests/README.md                  |  6 +++---
 tests/cases/03_byte_load_flash.c | 26 +++++++++++++-------------
 tests/cases/05_spiffs.c          |  4 ++--
 tests/test_main.c                | 16 ++++------------
 4 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/tests/README.md b/tests/README.md
index 070bf7d..9e2a6b9 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,6 +1,6 @@
 # esp-open-rtos tests
 
-Testing is based on [Unity](https://github.com/ThrowTheSwitch/Unity) 
+Testing is based on [Unity](https://github.com/ThrowTheSwitch/Unity)
 C testing framework.
 
 ## Features
@@ -24,10 +24,10 @@ reset into flash mode.
 `--type` or `-t` - Type of test case to run. Can be 'solo' or 'dual'.
 If not specified 'solo' test will be run.
 
-`--aport` or `-a` - Serial port for device A. 
+`--aport` or `-a` - Serial port for device A.
 If not specified device `/dev/ttyUSB0` is used.
 
-`--bport` or `-b` - Serial port for device B. 
+`--bport` or `-b` - Serial port for device B.
 If not specified device `/dev/ttyUSB1` is used.
 
 `--no-flash` or `-n` - Do not flash the test firmware before running tests.
diff --git a/tests/cases/03_byte_load_flash.c b/tests/cases/03_byte_load_flash.c
index fee464e..eccc01b 100644
--- a/tests/cases/03_byte_load_flash.c
+++ b/tests/cases/03_byte_load_flash.c
@@ -1,5 +1,5 @@
 /**
- * Unit tests to verify the "unaligned load handler" in core/exception_vectors.S 
+ * Unit tests to verify the "unaligned load handler" in core/exception_vectors.S
  * that allows us to complete byte loads from unaligned memory, etc.
  *
  * Adapted from a test program in 'experiments' that did this.
@@ -23,16 +23,16 @@
 
 static char dramtest[] = TESTSTRING;
 
-static const __attribute__((section(".iram1.notrodata"))) 
+static const __attribute__((section(".iram1.notrodata")))
     char iramtest[] = TESTSTRING;
 
-static const __attribute__((section(".text.notrodata"))) 
+static const __attribute__((section(".text.notrodata")))
     char iromtest[] = TESTSTRING;
 
-static const volatile __attribute__((section(".iram1.notliterals"))) 
+static const volatile __attribute__((section(".iram1.notliterals")))
     int16_t unsigned_shorts[] = { -3, -4, -5, -32767, 44 };
 
-static const __attribute__((section(".iram1.notrodata"))) 
+static const __attribute__((section(".iram1.notrodata")))
     char sanity_test_data[] = {
         0x01, 0x55, 0x7e, 0x2a, 0x81, 0xd5, 0xfe, 0xaa
     };
@@ -42,28 +42,28 @@ DEFINE_SOLO_TESTCASE(03_byte_load_verify_sections)
 #define PTR_IN_REGION(PTR, START, LEN) \
         ((START <= (intptr_t)(PTR)) && ((intptr_t)(PTR) < (START+LEN)))
 
-/* Sanity check, ensure the addresses of the various test strings 
+/* Sanity check, ensure the addresses of the various test strings
  * are in the correct address space regions. */
 static void a_03_byte_load_verify_sections()
 {
   printf("dramtest addr %p\n", dramtest);
-  TEST_ASSERT_MESSAGE(PTR_IN_REGION(dramtest, 0x3FFE8000, 0x14000), 
+  TEST_ASSERT_MESSAGE(PTR_IN_REGION(dramtest, 0x3FFE8000, 0x14000),
           "dramtest should be in DRAM region");
 
   printf("iramtest addr %p\n", iramtest);
-  TEST_ASSERT_MESSAGE(PTR_IN_REGION(iramtest, 0x40100000, 0x8000), 
+  TEST_ASSERT_MESSAGE(PTR_IN_REGION(iramtest, 0x40100000, 0x8000),
           "iramtest should be in IRAM region");
 
   printf("iromtest addr %p\n", iromtest);
-  TEST_ASSERT_MESSAGE(PTR_IN_REGION(iromtest, 0x40202010, (0x100000 - 0x2010)), 
+  TEST_ASSERT_MESSAGE(PTR_IN_REGION(iromtest, 0x40202010, (0x100000 - 0x2010)),
           "iromtest sohuld be in IROM region");
 
   printf("unsigned_shorts addr %p\n", unsigned_shorts);
-  TEST_ASSERT_MESSAGE(PTR_IN_REGION(unsigned_shorts, 0x40100000, 0x8000), 
+  TEST_ASSERT_MESSAGE(PTR_IN_REGION(unsigned_shorts, 0x40100000, 0x8000),
           "unsigned_shorts should be in IRAM region");
 
   printf("sanity_test_data addr %p\n", sanity_test_data);
-  TEST_ASSERT_MESSAGE(PTR_IN_REGION(sanity_test_data, 0x40100000, 0x8000), 
+  TEST_ASSERT_MESSAGE(PTR_IN_REGION(sanity_test_data, 0x40100000, 0x8000),
           "sanity_test_data should be in IRAM region");
 
   TEST_PASS();
@@ -224,8 +224,8 @@ static uint32_t IRAM inner_string_test(const char *string, test_with_fn_t testfn
       const char *expected = testfn(string);
       TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, buf, testfn_label);
       if(evict_cache) {
-	Cache_Read_Disable();
-	Cache_Read_Enable(0,0,1);
+        Cache_Read_Disable();
+        Cache_Read_Enable(0,0,1);
       }
     }
     uint32_t after;
diff --git a/tests/cases/05_spiffs.c b/tests/cases/05_spiffs.c
index 71f174e..ca15e1c 100644
--- a/tests/cases/05_spiffs.c
+++ b/tests/cases/05_spiffs.c
@@ -36,8 +36,8 @@ static void test_task(void *pvParameters)
 
     float write_rate, read_rate;
     if (fs_speed_test_run(get_current_time, &write_rate, &read_rate)) {
-        printf("Read speed: %.0f bytes/s\n", read_rate * 1000); 
-        printf("Write speed: %.0f bytes/s\n", write_rate * 1000); 
+        printf("Read speed: %.0f bytes/s\n", read_rate * 1000);
+        printf("Write speed: %.0f bytes/s\n", write_rate * 1000);
     } else {
         TEST_FAIL();
     }
diff --git a/tests/test_main.c b/tests/test_main.c
index aada715..efc61b1 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -33,7 +33,7 @@ void testcase_register(const testcase_t *testcase)
         testcases_alloc += 1;
         testcases = realloc(testcases, testcases_alloc * sizeof(testcase_t));
         if(!testcases) {
-            printf("Failed to reallocate test case register length %d\n", 
+            printf("Failed to reallocate test case register length %d\n",
                     testcases_alloc);
             testcases_count = 0;
             testcases_alloc = 0;
@@ -42,13 +42,14 @@ void testcase_register(const testcase_t *testcase)
     memcpy(&testcases[testcases_count++], testcase, sizeof(testcase_t));
 }
 
-static void test_task(void *pvParameters)
+void user_init(void)
 {
     uart_set_baud(0, 115200);
+    sdk_wifi_set_opmode(NULL_MODE);
     printf("esp-open-rtos test runner.\n");
     printf("%d test cases are defined:\n\n", testcases_count);
     for(int i = 0; i < testcases_count; i++) {
-        printf("CASE %d = %s %s\n", i, testcases[i].name, 
+        printf("CASE %d = %s %s\n", i, testcases[i].name,
                 get_requirements_name(testcases[i].type));
     }
 
@@ -118,13 +119,4 @@ static void test_task(void *pvParameters)
         testcase.a_fn();
     else
         testcase.b_fn();
-    /* TEST_FAIL_MESSAGE("\n\nTest initialisation routine returned" */
-    /*         " without calling TEST_PASS. Buggy test?"); */
-}
-
-void user_init(void)
-{
-    sdk_wifi_set_opmode(NULL_MODE);
-    test_task(0);
-    /* xTaskCreate(test_task, (signed char *)"test_task", 512, NULL, 2, NULL); */
 }