You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2019/01/08 12:09:16 UTC

[mynewt-core] 02/02: spiflash_stress_test: Add syscfg

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit fd48133c1bd2a139519c55e13b5d8a97fe6c906b
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Dec 14 16:25:56 2018 +0100

    spiflash_stress_test: Add syscfg
    
    syscfg allows to specify flash area to use for testing
    stack size can also be changed, default value works with ARM
    platforms but may not be enough for others.
---
 .../src/spiflash_stress_test.c                     | 19 +++++++++-------
 test/spiflash_stress_test/syscfg.yml               | 26 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/test/spiflash_stress_test/src/spiflash_stress_test.c b/test/spiflash_stress_test/src/spiflash_stress_test.c
index b733d97..6333133 100644
--- a/test/spiflash_stress_test/src/spiflash_stress_test.c
+++ b/test/spiflash_stress_test/src/spiflash_stress_test.c
@@ -27,13 +27,15 @@
 #include <stdio.h>
 #include <string.h>
 
+#define SPIFLASH_STRESS_TEST_TASK_COUNT 3
+
 struct runtest_task {
     struct os_task task;
     char name[sizeof "taskX"];
-    OS_TASK_STACK_DEFINE_NOSTATIC(stack, MYNEWT_VAL(RUNTEST_STACK_SIZE));
+    OS_TASK_STACK_DEFINE_NOSTATIC(stack, MYNEWT_VAL(SPIFLASH_STRESS_TEST_STACK_SIZE));
 };
 
-static struct runtest_task runtest_tasks[MYNEWT_VAL(RUNTEST_NUM_TASKS)];
+static struct runtest_task runtest_tasks[SPIFLASH_STRESS_TEST_TASK_COUNT];
 
 static int runtest_next_task_idx;
 
@@ -44,9 +46,9 @@ struct task_cfg {
     int increment;
     int pin;
 } task_args[] = {
-    { FLASH_AREA_TEST_1, 0x00000, 0x01000, 1, 11 },
-    { FLASH_AREA_TEST_1, 0x02000, 0x06000, 7, 12 },
-    { FLASH_AREA_TEST_1, 0x08000, 0x08000, 13, 13 },
+    { MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x00000, 0x01000, 1, 11 },
+    { MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x02000, 0x06000, 7, 12 },
+    { MYNEWT_VAL(SPIFLASH_STRESS_TEST_FLASH_AREA_ID), 0x08000, 0x08000, 13, 13 },
 };
 
 
@@ -59,7 +61,7 @@ runtest_init_task(os_task_func_t task_func, uint8_t prio)
     char *name;
     int rc;
 
-    if (runtest_next_task_idx >= MYNEWT_VAL(RUNTEST_NUM_TASKS)) {
+    if (runtest_next_task_idx >= SPIFLASH_STRESS_TEST_TASK_COUNT) {
         assert("No more test tasks");
         return NULL;
     }
@@ -74,7 +76,7 @@ runtest_init_task(os_task_func_t task_func, uint8_t prio)
 
     rc = os_task_init(task, name, task_func, &task_args[runtest_next_task_idx],
                       prio, OS_WAIT_FOREVER, stack,
-                      MYNEWT_VAL(RUNTEST_STACK_SIZE));
+                      MYNEWT_VAL(SPIFLASH_STRESS_TEST_STACK_SIZE));
     assert(rc == 0);
 
 #endif
@@ -135,7 +137,8 @@ void flash_test_task1(void *arg)
             os_time_delay(1);
             i += chunk;
         }
-        console_printf("Task %d waits\n", os_sched_get_current_task()->t_taskid);
+        console_printf("Task %d finished and waits for next start\n",
+                       os_sched_get_current_task()->t_taskid);
     }
 }
 
diff --git a/test/spiflash_stress_test/syscfg.yml b/test/spiflash_stress_test/syscfg.yml
new file mode 100644
index 0000000..c3ac7e6
--- /dev/null
+++ b/test/spiflash_stress_test/syscfg.yml
@@ -0,0 +1,26 @@
+# 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.
+#
+
+syscfg.defs:
+    SPIFLASH_STRESS_TEST_FLASH_AREA_ID:
+        description: 'Flash area ID to use for stress testing'
+        restriction: !null
+        value:
+    SPIFLASH_STRESS_TEST_STACK_SIZE:
+        description: 'Stack size for flash stressing tasks'
+        value: 150