You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by pe...@apache.org on 2016/11/04 23:05:37 UTC

incubator-mynewt-core git commit: MYNEWT-139 - runttest module in mynewt.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 029f64575 -> 7d080f729


MYNEWT-139 - runttest module in mynewt.

Embedded side of runtest command. Currently only launches single test in
mynewtsanity app.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7d080f72
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7d080f72
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7d080f72

Branch: refs/heads/develop
Commit: 7d080f729a2dd97360ce933f06b6c086d3165ab6
Parents: 029f645
Author: Peter Snyder <pe...@apache.org>
Authored: Fri Nov 4 15:47:40 2016 -0700
Committer: Peter Snyder <pe...@apache.org>
Committed: Fri Nov 4 15:58:29 2016 -0700

----------------------------------------------------------------------
 test/runtest/include/runtest/runtest.h | 40 +++++++++++++
 test/runtest/pkg.yml                   | 36 ++++++++++++
 test/runtest/src/runtest.c             | 61 ++++++++++++++++++++
 test/runtest/src/runtest_cli.c         | 46 +++++++++++++++
 test/runtest/src/runtest_nmgr.c        | 87 +++++++++++++++++++++++++++++
 test/runtest/src/runtest_priv.h        | 39 +++++++++++++
 test/runtest/syscfg.yml                | 11 ++++
 7 files changed, 320 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d080f72/test/runtest/include/runtest/runtest.h
----------------------------------------------------------------------
diff --git a/test/runtest/include/runtest/runtest.h b/test/runtest/include/runtest/runtest.h
new file mode 100644
index 0000000..f5d7959
--- /dev/null
+++ b/test/runtest/include/runtest/runtest.h
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+#ifndef __RUNTEST_H__
+#define __RUNTEST_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Adds the run test commands to your shell/newtmgr.
+ */
+void runtest_init(void);
+
+/*
+ * XXX global used to gate starting test - hack
+ */
+extern int runtest_start;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __RUNTEST_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d080f72/test/runtest/pkg.yml
----------------------------------------------------------------------
diff --git a/test/runtest/pkg.yml b/test/runtest/pkg.yml
new file mode 100644
index 0000000..e64f12a
--- /dev/null
+++ b/test/runtest/pkg.yml
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+pkg.name: test/runtest
+pkg.description: Allow control over launching test suites
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps.RUNTEST_CLI:
+    - sys/shell
+pkg.req_apis.RUNTEST_CLI:
+    - console
+pkg.deps.RUNTEST_NEWTMGR:
+    - mgmt/mgmt
+
+pkg.deps.RUNTEST_NEWTMGR:
+    - encoding/json
+
+pkg.init_function: runtest_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d080f72/test/runtest/src/runtest.c
----------------------------------------------------------------------
diff --git a/test/runtest/src/runtest.c b/test/runtest/src/runtest.c
new file mode 100644
index 0000000..87aaa5d
--- /dev/null
+++ b/test/runtest/src/runtest.c
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "syscfg/syscfg.h"
+#include "os/os.h"
+#include "console/console.h"
+
+#include "runtest/runtest.h"
+#include "runtest_priv.h"
+
+#if MYNEWT_VAL(RUNTEST_CLI)
+#include "shell/shell.h"
+struct shell_cmd runtest_cmd_struct;
+#endif
+
+#if MYNEWT_VAL(RUNTEST_NEWTMGR)
+#include "mgmt/mgmt.h"
+struct mgmt_group runtest_nmgr_group;
+#endif
+
+int
+runtest()
+{
+    /* XXX */
+
+    return 0;
+}
+
+void
+runtest_init(void)
+{
+    runtest_start = 1;
+
+#if MYNEWT_VAL(RUNTEST_CLI)
+    shell_cmd_register(&runtest_cmd_struct);
+#endif
+
+#if MYNEWT_VAL(RUNTEST_NEWTMGR)
+    mgmt_group_register(&runtest_nmgr_group);
+#endif
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d080f72/test/runtest/src/runtest_cli.c
----------------------------------------------------------------------
diff --git a/test/runtest/src/runtest_cli.c b/test/runtest/src/runtest_cli.c
new file mode 100644
index 0000000..282663c
--- /dev/null
+++ b/test/runtest/src/runtest_cli.c
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(RUNTEST_CLI)
+#include <inttypes.h>
+#include <os/os.h>
+#include <console/console.h>
+#include <shell/shell.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "runtest/runtest.h"
+#include "runtest_priv.h"
+
+static int runtest_cli_cmd(int argc, char **argv);
+struct shell_cmd runtest_cmd_struct = {
+    .sc_cmd = "runtest",
+    .sc_cmd_func = runtest_cli_cmd
+};
+
+static int
+runtest_cli_cmd(int argc, char **argv)
+{
+    console_printf("Usage runtest \n");
+    return 0;
+}
+
+#endif /* MYNEWT_VAL(RUNTEST_CLI) */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d080f72/test/runtest/src/runtest_nmgr.c
----------------------------------------------------------------------
diff --git a/test/runtest/src/runtest_nmgr.c b/test/runtest/src/runtest_nmgr.c
new file mode 100644
index 0000000..66b3372
--- /dev/null
+++ b/test/runtest/src/runtest_nmgr.c
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+#include "syscfg/syscfg.h"
+
+#if MYNEWT_VAL(RUNTEST_NEWTMGR)
+#include <string.h>
+
+#include "mgmt/mgmt.h"
+#include "cborattr/cborattr.h"
+#include "console/console.h"
+
+#include "runtest/runtest.h"
+#include "runtest_priv.h"
+
+static int runtest_nmgr_write(struct mgmt_cbuf *);
+
+static const struct mgmt_handler runtest_nmgr_handler[] = {
+    [0] = { runtest_nmgr_write, runtest_nmgr_write }
+};
+
+struct mgmt_group runtest_nmgr_group = {
+    .mg_handlers = (struct mgmt_handler *)runtest_nmgr_handler,
+    .mg_handlers_count = 1,
+    .mg_group_id = MGMT_GROUP_ID_RUNTEST
+};
+
+/*
+ * XXX global used to gate starting test - hack
+ */
+int runtest_start;
+
+static int
+runtest_nmgr_write(struct mgmt_cbuf *cb)
+{
+    char tmp_str[64];
+    const struct cbor_attr_t attr[2] = {
+        [0] = {
+            .attribute = "u",
+            .type = CborAttrTextStringType,
+            .addr.string = tmp_str,
+            .len = sizeof(tmp_str)
+        },
+        [1] = {
+            .attribute = NULL
+        }
+    };
+    int rc;
+
+    rc = cbor_read_object(&cb->it, attr);
+    if (rc) {
+        rc = MGMT_ERR_EINVAL;
+    } else {
+        /* XXX ugh - drop out of a loop allowing a test to run in an app */
+        runtest_start = 0;
+        /*
+         * we should be doing something more like this where we call
+         * a named test suite directly
+         */
+#ifdef NOTYET
+        rc = start_test(tmp_str);
+#endif
+        if (rc) {
+            rc = MGMT_ERR_EINVAL;
+        }
+    }
+    mgmt_cbuf_setoerr(cb, rc);
+    return 0;
+}
+
+#endif /* MYNEWT_VAL(RUNTEST_NEWTMGR) */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d080f72/test/runtest/src/runtest_priv.h
----------------------------------------------------------------------
diff --git a/test/runtest/src/runtest_priv.h b/test/runtest/src/runtest_priv.h
new file mode 100644
index 0000000..af43895
--- /dev/null
+++ b/test/runtest/src/runtest_priv.h
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+#ifndef __RUNTEST_PRIV_H__
+#define __RUNTEST_PRIV_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if MYNEWT_VAL(RUNTEST_CLI)
+extern struct shell_cmd runtest_cmd_struct;
+#endif
+#if MYNEWT_VAL(RUNTEST_NEWTMGR)
+extern struct mgmt_group runtest_nmgr_group;
+#endif
+
+int runtest();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __RUNTEST_PRIV_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d080f72/test/runtest/syscfg.yml
----------------------------------------------------------------------
diff --git a/test/runtest/syscfg.yml b/test/runtest/syscfg.yml
new file mode 100644
index 0000000..9e78bf3
--- /dev/null
+++ b/test/runtest/syscfg.yml
@@ -0,0 +1,11 @@
+# Package: test/runtest
+
+syscfg.defs:
+    RUNTEST_CLI:
+        description: 'TBD'
+        value: 1
+        restrictions:
+            - SHELL_TASK
+    RUNTEST_NEWTMGR:
+        description: 'TBD'
+        value: 1