You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ad...@apache.org on 2016/03/01 09:11:40 UTC
[1/4] incubator-mynewt-site git commit: Documentation for testutil.
Repository: incubator-mynewt-site
Updated Branches:
refs/heads/master cb135eca7 -> 9f2100c7b
Documentation for testutil.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/cf8df14f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/cf8df14f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/cf8df14f
Branch: refs/heads/master
Commit: cf8df14fe9d8acc866da7b3d188539f5127211ef
Parents: cb135ec
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Feb 29 15:26:50 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Feb 29 15:26:50 2016 -0800
----------------------------------------------------------------------
docs/os/modules/testutil/test_assert.md | 76 ++++++++++++++++
docs/os/modules/testutil/test_case.md | 29 ++++++
docs/os/modules/testutil/test_pass.md | 31 +++++++
docs/os/modules/testutil/test_suite.md | 33 +++++++
docs/os/modules/testutil/testutil.md | 96 +++++++++++++++-----
docs/os/modules/testutil/tu_case_abort.md | 0
.../testutil/tu_case_append_assert_msg.md | 0
docs/os/modules/testutil/tu_case_append_buf.md | 0
.../testutil/tu_case_append_file_info.md | 0
.../testutil/tu_case_append_manual_pass_msg.md | 0
docs/os/modules/testutil/tu_case_complete.md | 0
docs/os/modules/testutil/tu_case_fail_assert.md | 0
docs/os/modules/testutil/tu_case_init.md | 0
docs/os/modules/testutil/tu_case_pass_manual.md | 0
docs/os/modules/testutil/tu_case_set_name.md | 0
docs/os/modules/testutil/tu_case_vappend_buf.md | 0
.../modules/testutil/tu_case_write_fail_buf.md | 0
.../modules/testutil/tu_case_write_pass_auto.md | 0
.../modules/testutil/tu_case_write_pass_buf.md | 0
docs/os/modules/testutil/tu_init.md | 39 ++++++++
docs/os/modules/testutil/tu_restart.md | 33 +++++++
docs/os/modules/testutil/tu_suite_init.md | 0
docs/os/modules/testutil/tu_suite_set_name.md | 0
23 files changed, 316 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/test_assert.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_assert.md b/docs/os/modules/testutil/test_assert.md
new file mode 100644
index 0000000..07448d4
--- /dev/null
+++ b/docs/os/modules/testutil/test_assert.md
@@ -0,0 +1,76 @@
+## <font color="F2853F" style="font-size:24pt"> TEST_ASSERT</font>
+
+```no-highlight
+TEST_ASSERT(expression, fail_msg, ...)
+```
+```no-highlight
+TEST_ASSERT_FATAL(expression, fail_msg, ...)
+```
+
+Asserts that the specified condition is true. If the expression is true, nothing gets reported. *fail_msg* will be printed out if the expression is false. The expression argument is mandatory; the rest are optional. The fail_msg argument is a printf format string which specifies how the remaining arguments are parsed.
+
+TEST_ASSERT_FATAL() causes the current test case to be aborted, if expression fails.
+
+#### Arguments
+
+| Arguments | Description |
+|-----------|-------------|
+| expression | Condition being tested. If it fails, test is considered a failure, and a message is printed out. |
+| fail_msg | Pointer to C string that contains a format string that follows the same specifications as format in printf. |
+| ... | Depending on the format string, the function may expect either a sequence of additional arguments to be used to replace a format specifier in the format string or a variable arguments list. va_list is a special type defined in <cstdarg> in stdarg.h. |
+
+#### Returned values
+
+None
+
+#### Notes
+
+While `console_printf`, with its well understood formatting options in C, is more convenient and easy on the eyes than the raw output of `console_write`, the associated code size is considerably larger.
+
+#### Example
+Example #1:
+
+```no-highlight
+TEST_CASE(config_test_insert)
+{
+ int rc;
+
+ rc = conf_register(&config_test_handler);
+ TEST_ASSERT(rc == 0);
+}
+```
+
+Example #2:
+
+```no-highlight
+TEST_CASE(nffs_test_unlink)
+{
+ int rc;
+
+ ....
+
+ rc = nffs_format(nffs_area_descs);
+ TEST_ASSERT_FATAL(rc == 0);
+
+ ....
+}
+```
+
+Example #3:
+
+```no-highlight
+
+static int
+cbmem_test_case_1_walk(struct cbmem *cbmem, struct cbmem_entry_hdr *hdr,
+ void *arg)
+{
+ ....
+
+ rc = cbmem_read(cbmem, hdr, &actual, 0, sizeof(actual));
+ TEST_ASSERT_FATAL(rc == 1, "Couldn't read 1 byte from cbmem");
+ TEST_ASSERT_FATAL(actual == expected,
+ "Actual doesn't equal expected (%d = %d)", actual, expected);
+
+ ....
+}
+```
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/test_case.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_case.md b/docs/os/modules/testutil/test_case.md
new file mode 100644
index 0000000..0b7de09
--- /dev/null
+++ b/docs/os/modules/testutil/test_case.md
@@ -0,0 +1,29 @@
+## <font color="F2853F" style="font-size:24pt"> TEST_CASE </font>
+
+```no-highlight
+TEST_CASE(test_case_name)
+```
+
+Declares a test case function with the following type *int test_case_name(void)*. This can then be called from regression test's *TEST_SUITE()* function.
+
+#### Arguments
+
+| Arguments | Description |
+|-----------|-------------|
+| test_case_name | Used as the function name for this test case. |
+
+#### Returned values
+
+Return value is 0 if the test case passed; nonzero if it failed. Generally, the return code is not used. It is expected that the case will pass/fail with tests done using *TEST_ASSERT()*.
+
+#### Notes
+
+
+#### Example
+
+```no-highlight
+TEST_CASE(config_test_insert)
+{
+ ....
+}
+```
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/test_pass.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_pass.md b/docs/os/modules/testutil/test_pass.md
new file mode 100644
index 0000000..0bcbd8c
--- /dev/null
+++ b/docs/os/modules/testutil/test_pass.md
@@ -0,0 +1,31 @@
+## <font color="F2853F" style="font-size:24pt"> TEST_PASS </font>
+
+```no-highlight
+TEST_PASS(msg, ...)
+```
+
+Reports a success result for the current test. This function is not normally needed, as all successful tests automatically write an empty pass result at completion. It is only needed when the success result report should contain text. The msg argument is a printf format string
+ which specifies how the remaining arguments are parsed. The result file
+ produced by this function contains the following text:
+
+ |<file>:<line-number>| manual pass
+ <msg>
+
+
+TEST_ASSERT_FATAL() causes the current test case to be aborted, if expression fails.
+
+#### Arguments
+
+| Arguments | Description |
+|-----------|-------------|
+| msg | This is a printf format string which specifies how the remaining arguments are parsed |
+| ... | Depending on the format string, the function may expect either a sequence of additional arguments to be used to replace a format specifier in the format string or a variable arguments list. va_list is a special type defined in <cstdarg> in stdarg.h. |
+
+#### Returned values
+
+None
+
+#### Notes
+
+After this function is called, the remainder of the test case is not executed.
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/test_suite.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_suite.md b/docs/os/modules/testutil/test_suite.md
new file mode 100644
index 0000000..f147efd
--- /dev/null
+++ b/docs/os/modules/testutil/test_suite.md
@@ -0,0 +1,33 @@
+## <font color="F2853F" style="font-size:24pt"> TEST_SUITE </font>
+
+```no-highlight
+TEST_SUITE(test_suite_name)
+```
+
+Declares a test suite function with the following type *int test_suite_name(void)*. This can then be called from either *project/test*, or from main routine for package specific regression test.
+
+#### Arguments
+
+| Arguments | Description |
+|-----------|-------------|
+| test_suite_name | Used as the function name for this test suite. |
+
+#### Returned values
+
+Return value is 0 if the test suite passed; nonzero if it failed. Generally, the return code is not used. It is expected that the individual test cases will pass/fail with tests done using *TEST_ASSERT()*.
+
+#### Notes
+
+
+#### Example
+
+```no-highlight
+TEST_SUITE(os_sem_test_suite)
+{
+ os_sem_test_basic();
+ os_sem_test_case_1();
+ os_sem_test_case_2();
+ os_sem_test_case_3();
+ os_sem_test_case_4();
+}
+```
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/testutil.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/testutil.md b/docs/os/modules/testutil/testutil.md
index 821f64b..690fc32 100644
--- a/docs/os/modules/testutil/testutil.md
+++ b/docs/os/modules/testutil/testutil.md
@@ -1,38 +1,92 @@
# testutil
-Insert synopsis here
+The testutil package is a test framework that provides facilities for specifying test cases and recording test results.
+You would use it to build regression tests for your library.
## Description
-Describe module here, special features, how pieces fit together etc.
+Tests are structures according to the following hierarchy:
+
+ [test]
+ / \
+ [suite] [suite]
+ / \ / \
+ [case] [case] [case] [case]
+
+
+I.e., a test consists of test suites, and a test suite consists of test cases.
+
+The test code uses testutil to define test suites and test cases.
+
+Regression test can then be executed using 'newt target test' command, or by including a call to your test suite from *project/test/src/test.c*.
+
+### Example
+
+The following example demonstrates how to create a simple test suite.
+
+```no-highlight
+ TEST_CASE(test_addition)
+ {
+ int sum;
+
+ sum = 5 + 10;
+ TEST_ASSERT(sum == 15, "actual value: %d", sum);
+ }
+
+ TEST_CASE(test_times_0)
+ {
+ TEST_ASSERT(3 * 0 == 0);
+ TEST_ASSERT(4 * 0 == 0);
+ TEST_ASSERT(712 * 0 == 0);
+ }
+
+ TEST_SUITE(test_suite_arithmetic)
+ {
+ test_addition();
+ test_times_0();
+ }
+```
+
+The test suite would then be executed via a call to test_suite_arithmetic().
## Data structures
-Replace this with the list of data structures used, why, any neat features
+```no-highlight
+struct tu_config {
+ int tc_print_results;
+ int tc_system_assert;
+
+ tu_case_init_fn_t *tc_case_init_cb;
+ void *tc_case_init_arg;
+
+ tu_case_report_fn_t *tc_case_fail_cb;
+ void *tc_case_fail_arg;
+
+ tu_case_report_fn_t *tc_case_pass_cb;
+ void *tc_case_pass_arg;
+
+ tu_suite_init_fn_t *tc_suite_init_cb;
+ void *tc_suite_init_arg;
+
+ tu_restart_fn_t *tc_restart_cb;
+ void *tc_restart_arg;
+};
+extern struct tu_config tu_config;
+```
+The global tu_config struct contains all the testutil package's settings.
+This should be populated before *tu_init()* is called.
## List of Functions
<Comments such as these instructions are placed within angle brackets. List all the functions here. Note how the anchors work. You put the text you want to show up as a link within [] and the relevant #heading within (). Note that the header has to have at least 2 words for the anchor to work - that's how it is. "no-highlight" disables syntax highlighting. You can enable it for a particular language by specifying what the language is instead of "no-highlight". Be warned that this highlighting or no-highlighting specification may not show up nicely on Mou.>
-The functions available in testutil are:
-
-* [tu_case_abort](tu_case_abort.md)
-* [tu_case_append_assert_msg](tu_case_append_assert_msg.md)
-* [tu_case_append_buf](tu_case_append_buf.md)
-* [tu_case_append_file_info](tu_case_append_file_info.md)
-* [tu_case_append_manual_pass_msg](tu_case_append_manual_pass_msg.md)
-* [tu_case_complete](tu_case_complete.md)
-* [tu_case_fail_assert](tu_case_fail_assert.md)
-* [tu_case_init](tu_case_init.md)
-* [tu_case_pass_manual](tu_case_pass_manual.md)
-* [tu_case_set_name](tu_case_set_name.md)
-* [tu_case_vappend_buf](tu_case_vappend_buf.md)
-* [tu_case_write_fail_buf](tu_case_write_fail_buf.md)
-* [tu_case_write_pass_auto](tu_case_write_pass_auto.md)
-* [tu_case_write_pass_buf](tu_case_write_pass_buf.md)
+The functions, and macros available in testutil are:
+
* [tu_init](tu_init.md)
+* [TEST_ASSERT](test_assert.md)
+* [TEST_PASS](test_pass.md)
+* [TEST_SUITE](test_suite.md)
+* [TEST_CASE](test_case.md)
* [tu_restart](tu_restart.md)
-* [tu_suite_init](tu_suite_init.md)
-* [tu_suite_set_name](tu_suite_set_name.md)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_abort.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_abort.md b/docs/os/modules/testutil/tu_case_abort.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_append_assert_msg.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_append_assert_msg.md b/docs/os/modules/testutil/tu_case_append_assert_msg.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_append_buf.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_append_buf.md b/docs/os/modules/testutil/tu_case_append_buf.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_append_file_info.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_append_file_info.md b/docs/os/modules/testutil/tu_case_append_file_info.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_append_manual_pass_msg.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_append_manual_pass_msg.md b/docs/os/modules/testutil/tu_case_append_manual_pass_msg.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_complete.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_complete.md b/docs/os/modules/testutil/tu_case_complete.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_fail_assert.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_fail_assert.md b/docs/os/modules/testutil/tu_case_fail_assert.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_init.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_init.md b/docs/os/modules/testutil/tu_case_init.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_pass_manual.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_pass_manual.md b/docs/os/modules/testutil/tu_case_pass_manual.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_set_name.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_set_name.md b/docs/os/modules/testutil/tu_case_set_name.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_vappend_buf.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_vappend_buf.md b/docs/os/modules/testutil/tu_case_vappend_buf.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_write_fail_buf.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_write_fail_buf.md b/docs/os/modules/testutil/tu_case_write_fail_buf.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_write_pass_auto.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_write_pass_auto.md b/docs/os/modules/testutil/tu_case_write_pass_auto.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_case_write_pass_buf.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_case_write_pass_buf.md b/docs/os/modules/testutil/tu_case_write_pass_buf.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_init.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_init.md b/docs/os/modules/testutil/tu_init.md
index e69de29..d098617 100644
--- a/docs/os/modules/testutil/tu_init.md
+++ b/docs/os/modules/testutil/tu_init.md
@@ -0,0 +1,39 @@
+## <font color="F2853F" style="font-size:24pt"> console_printf</font>
+
+```no-highlight
+int tu_init(void)
+```
+
+Initializes the test framework according to the contents of the tu_config struct. This function must be called before any tests are run.
+
+#### Arguments
+
+N/A
+
+#### Returned values
+
+Returns 0 on success; nonzero on failure.
+
+#### Notes
+
+#### Example
+
+Here's an example of stand-alone code which allows the user to execute regression tests for sys/config package only.
+
+```no-highlight
+#ifdef PKG_TEST
+
+int
+main(int argc, char **argv)
+{
+ tu_config.tc_print_results = 1;
+ tu_init();
+
+ conf_init();
+ config_test_all();
+
+ return tu_any_failed;
+}
+
+#endif
+```
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_restart.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_restart.md b/docs/os/modules/testutil/tu_restart.md
index e69de29..b9cea2a 100644
--- a/docs/os/modules/testutil/tu_restart.md
+++ b/docs/os/modules/testutil/tu_restart.md
@@ -0,0 +1,33 @@
+## <font color="F2853F" style="font-size:24pt"> tu_restart </font>
+
+```no-highlight
+void tu_restart(void)
+```
+
+This function is used when a system reset is necessary to proceed with testing. For example, the OS is designed to run forever once started, so a test which creates several OS tasks and then starts the OS has no means of completing. This function, when called from such a test, gracefully ends the current test case and proceeds to the next test case.
+
+The particulars of this function depend on whether it is called from a simulated environment. In a simulated environment, this function uses a longjmp() call to break out of the current test case.
+
+
+#### Arguments
+
+N/A
+
+#### Returned values
+
+Returns 0 on success; nonzero on failure.
+
+#### Notes
+
+#### Example
+
+```no-highlight
+void
+os_test_restart(void)
+{
+ ....
+
+ tu_restart();
+}
+#endif
+```
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_suite_init.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_suite_init.md b/docs/os/modules/testutil/tu_suite_init.md
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/cf8df14f/docs/os/modules/testutil/tu_suite_set_name.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_suite_set_name.md b/docs/os/modules/testutil/tu_suite_set_name.md
deleted file mode 100644
index e69de29..0000000
[3/4] incubator-mynewt-site git commit: Add more meat to description.
Posted by ad...@apache.org.
Add more meat to description.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/1ff40e62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/1ff40e62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/1ff40e62
Branch: refs/heads/master
Commit: 1ff40e62b3a3ae25dffe60cc9b5babf8c02515a1
Parents: a268407
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Feb 29 16:01:27 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Feb 29 16:01:27 2016 -0800
----------------------------------------------------------------------
docs/os/modules/testutil/testutil.md | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/1ff40e62/docs/os/modules/testutil/testutil.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/testutil.md b/docs/os/modules/testutil/testutil.md
index 690fc32..64df5ef 100644
--- a/docs/os/modules/testutil/testutil.md
+++ b/docs/os/modules/testutil/testutil.md
@@ -7,6 +7,27 @@ You would use it to build regression tests for your library.
## Description
+A package may optionally contain a set of test cases. Test cases are not normally compiled and linked when a package is built; they are only included
+when the "test" identity is specified. All of a package's test code goes in its 'src/test' directory. For example, the nffs package's test code is located in the following directory:
+
+ fs/nffs/src/test/
+
+This directory contains the source and header files that implement the nffs test code.
+
+The test code has access to all the header files in the following directories:
+ * src
+ * src/arch/<target-arch>
+ * include
+ * src/test
+ * src/test/arch/<target-arch>
+ * include directories of all package dependencies
+
+Package test code typically depends on the testutil package, described later in this document. If a package's test code uses testutil, then the package itself needs to have testutil in its dependency list.
+
+Some test cases or test initialization code may be platform-specific. In such cases, the platform-specific function definitions are placed in arch subdirectories within the package test directory.
+
+When test code is built (i.e., when the "test" identity is specified), the newt tool defines the "TEST" macro. This macro is defined during compilation of all C source files in all projects and packages.
+
Tests are structures according to the following hierarchy:
[test]
[4/4] incubator-mynewt-site git commit: Testutil documentation added.
This closes #16 .
Posted by ad...@apache.org.
Testutil documentation added. This closes #16 .
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/9f2100c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/9f2100c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/9f2100c7
Branch: refs/heads/master
Commit: 9f2100c7b20f564f78fccc8b306f947505537ad2
Parents: 1ff40e6
Author: aditihilbert <ad...@runtime.io>
Authored: Tue Mar 1 00:11:33 2016 -0800
Committer: aditihilbert <ad...@runtime.io>
Committed: Tue Mar 1 00:11:33 2016 -0800
----------------------------------------------------------------------
docs/os/modules/testutil/test_assert.md | 2 +-
docs/os/modules/testutil/test_case.md | 6 ++----
docs/os/modules/testutil/test_pass.md | 6 ++----
docs/os/modules/testutil/test_suite.md | 7 ++-----
docs/os/modules/testutil/testutil.md | 27 ++++++++++++++-------------
docs/os/modules/testutil/tu_init.md | 6 ++----
docs/os/modules/testutil/tu_restart.md | 4 +---
7 files changed, 24 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9f2100c7/docs/os/modules/testutil/test_assert.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_assert.md b/docs/os/modules/testutil/test_assert.md
index 07448d4..44495ed 100644
--- a/docs/os/modules/testutil/test_assert.md
+++ b/docs/os/modules/testutil/test_assert.md
@@ -9,7 +9,7 @@ TEST_ASSERT_FATAL(expression, fail_msg, ...)
Asserts that the specified condition is true. If the expression is true, nothing gets reported. *fail_msg* will be printed out if the expression is false. The expression argument is mandatory; the rest are optional. The fail_msg argument is a printf format string which specifies how the remaining arguments are parsed.
-TEST_ASSERT_FATAL() causes the current test case to be aborted, if expression fails.
+`TEST_ASSERT_FATAL()` causes the current test case to be aborted, if expression fails.
#### Arguments
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9f2100c7/docs/os/modules/testutil/test_case.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_case.md b/docs/os/modules/testutil/test_case.md
index 0b7de09..61a7aef 100644
--- a/docs/os/modules/testutil/test_case.md
+++ b/docs/os/modules/testutil/test_case.md
@@ -4,7 +4,7 @@
TEST_CASE(test_case_name)
```
-Declares a test case function with the following type *int test_case_name(void)*. This can then be called from regression test's *TEST_SUITE()* function.
+Declares a test case function with the following type `int test_case_name(void)`. This can then be called from regression test's `TEST_SUITE()` function.
#### Arguments
@@ -14,9 +14,7 @@ Declares a test case function with the following type *int test_case_name(void)*
#### Returned values
-Return value is 0 if the test case passed; nonzero if it failed. Generally, the return code is not used. It is expected that the case will pass/fail with tests done using *TEST_ASSERT()*.
-
-#### Notes
+Return value is 0 if the test case passed; nonzero if it failed. Generally, the return code is not used. It is expected that the case will pass/fail with tests done using `TEST_ASSERT()`.
#### Example
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9f2100c7/docs/os/modules/testutil/test_pass.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_pass.md b/docs/os/modules/testutil/test_pass.md
index 0bcbd8c..0933ea6 100644
--- a/docs/os/modules/testutil/test_pass.md
+++ b/docs/os/modules/testutil/test_pass.md
@@ -7,12 +7,10 @@ TEST_PASS(msg, ...)
Reports a success result for the current test. This function is not normally needed, as all successful tests automatically write an empty pass result at completion. It is only needed when the success result report should contain text. The msg argument is a printf format string
which specifies how the remaining arguments are parsed. The result file
produced by this function contains the following text:
-
+```no-highlight
|<file>:<line-number>| manual pass
<msg>
-
-
-TEST_ASSERT_FATAL() causes the current test case to be aborted, if expression fails.
+```
#### Arguments
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9f2100c7/docs/os/modules/testutil/test_suite.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/test_suite.md b/docs/os/modules/testutil/test_suite.md
index f147efd..b333883 100644
--- a/docs/os/modules/testutil/test_suite.md
+++ b/docs/os/modules/testutil/test_suite.md
@@ -4,7 +4,7 @@
TEST_SUITE(test_suite_name)
```
-Declares a test suite function with the following type *int test_suite_name(void)*. This can then be called from either *project/test*, or from main routine for package specific regression test.
+Declares a test suite function with the following type `int test_suite_name(void)`. This can then be called from either *project/test*, or from main routine for package specific regression test.
#### Arguments
@@ -14,10 +14,7 @@ Declares a test suite function with the following type *int test_suite_name(void
#### Returned values
-Return value is 0 if the test suite passed; nonzero if it failed. Generally, the return code is not used. It is expected that the individual test cases will pass/fail with tests done using *TEST_ASSERT()*.
-
-#### Notes
-
+Return value is 0 if the test suite passed; nonzero if it failed. Generally, the return code is not used. It is expected that the individual test cases will pass/fail with tests done using `TEST_ASSERT()`.
#### Example
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9f2100c7/docs/os/modules/testutil/testutil.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/testutil.md b/docs/os/modules/testutil/testutil.md
index 64df5ef..03ad6ec 100644
--- a/docs/os/modules/testutil/testutil.md
+++ b/docs/os/modules/testutil/testutil.md
@@ -8,40 +8,41 @@ You would use it to build regression tests for your library.
## Description
A package may optionally contain a set of test cases. Test cases are not normally compiled and linked when a package is built; they are only included
-when the "test" identity is specified. All of a package's test code goes in its 'src/test' directory. For example, the nffs package's test code is located in the following directory:
-
- fs/nffs/src/test/
-
+when the "test" identity is specified. All of a package's test code goes in its `src/test` directory. For example, the nffs package's test code is located in the following directory:
+```no-highlight
+ * fs/nffs/src/test/
+```
This directory contains the source and header files that implement the nffs test code.
The test code has access to all the header files in the following directories:
+```no-highlight
* src
* src/arch/<target-arch>
* include
* src/test
* src/test/arch/<target-arch>
* include directories of all package dependencies
-
+```
Package test code typically depends on the testutil package, described later in this document. If a package's test code uses testutil, then the package itself needs to have testutil in its dependency list.
Some test cases or test initialization code may be platform-specific. In such cases, the platform-specific function definitions are placed in arch subdirectories within the package test directory.
-When test code is built (i.e., when the "test" identity is specified), the newt tool defines the "TEST" macro. This macro is defined during compilation of all C source files in all projects and packages.
-
-Tests are structures according to the following hierarchy:
+While building the test code (i.e., when the `test` identity is specified), the newt tool defines the `TEST` macro. This macro is defined during compilation of all C source files in all projects and packages.
+Tests are structured according to the following hierarchy:
+```no-highlight
[test]
/ \
[suite] [suite]
/ \ / \
[case] [case] [case] [case]
-
+```
I.e., a test consists of test suites, and a test suite consists of test cases.
The test code uses testutil to define test suites and test cases.
-Regression test can then be executed using 'newt target test' command, or by including a call to your test suite from *project/test/src/test.c*.
+Regression test can then be executed using 'newt target test' command, or by including a call to your test suite from `project/test/src/test.c`.
### Example
@@ -70,7 +71,7 @@ The following example demonstrates how to create a simple test suite.
}
```
-The test suite would then be executed via a call to test_suite_arithmetic().
+The test suite would then be executed via a call to `test_suite_arithmetic()`.
## Data structures
@@ -96,8 +97,8 @@ struct tu_config {
};
extern struct tu_config tu_config;
```
-The global tu_config struct contains all the testutil package's settings.
-This should be populated before *tu_init()* is called.
+The global `tu_config` struct contains all the testutil package's settings.
+This should be populated before `tu_init()` is called.
## List of Functions
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9f2100c7/docs/os/modules/testutil/tu_init.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_init.md b/docs/os/modules/testutil/tu_init.md
index d098617..f785cbb 100644
--- a/docs/os/modules/testutil/tu_init.md
+++ b/docs/os/modules/testutil/tu_init.md
@@ -1,10 +1,10 @@
-## <font color="F2853F" style="font-size:24pt"> console_printf</font>
+## <font color="F2853F" style="font-size:24pt"> tu_init</font>
```no-highlight
int tu_init(void)
```
-Initializes the test framework according to the contents of the tu_config struct. This function must be called before any tests are run.
+Initializes the test framework according to the contents of the `tu_config` struct. This function must be called before any tests are run.
#### Arguments
@@ -14,8 +14,6 @@ N/A
Returns 0 on success; nonzero on failure.
-#### Notes
-
#### Example
Here's an example of stand-alone code which allows the user to execute regression tests for sys/config package only.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/9f2100c7/docs/os/modules/testutil/tu_restart.md
----------------------------------------------------------------------
diff --git a/docs/os/modules/testutil/tu_restart.md b/docs/os/modules/testutil/tu_restart.md
index b9cea2a..0f6dfd8 100644
--- a/docs/os/modules/testutil/tu_restart.md
+++ b/docs/os/modules/testutil/tu_restart.md
@@ -6,7 +6,7 @@ void tu_restart(void)
This function is used when a system reset is necessary to proceed with testing. For example, the OS is designed to run forever once started, so a test which creates several OS tasks and then starts the OS has no means of completing. This function, when called from such a test, gracefully ends the current test case and proceeds to the next test case.
-The particulars of this function depend on whether it is called from a simulated environment. In a simulated environment, this function uses a longjmp() call to break out of the current test case.
+The particulars of this function depend on whether it is called from a simulated environment. In a simulated environment, this function uses a `longjmp()` call to break out of the current test case.
#### Arguments
@@ -17,8 +17,6 @@ N/A
Returns 0 on success; nonzero on failure.
-#### Notes
-
#### Example
```no-highlight
[2/4] incubator-mynewt-site git commit: Update with updated list of
testutil files.
Posted by ad...@apache.org.
Update with updated list of testutil files.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/commit/a268407d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/tree/a268407d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/diff/a268407d
Branch: refs/heads/master
Commit: a268407d8b320c5d612a8657b715e3e92e582c34
Parents: cf8df14
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Feb 29 15:30:29 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Feb 29 15:30:29 2016 -0800
----------------------------------------------------------------------
mkdocs.yml | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/a268407d/mkdocs.yml
----------------------------------------------------------------------
diff --git a/mkdocs.yml b/mkdocs.yml
index 1788c00..29f7ad0 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -202,25 +202,13 @@ pages:
- 'Newtron Flash File System': 'os/modules/nffs.md'
- Test Utilities:
- 'Overview': 'os/modules/testutil/testutil.md'
- - 'Functions':
- - 'tu_case_abort': 'os/modules/testutil/tu_case_abort.md'
- - 'tu_case_append_assert_msg': 'os/modules/testutil/tu_case_append_assert_msg.md'
- - 'tu_case_append_buf': 'os/modules/testutil/tu_case_append_buf.md'
- - 'tu_case_append_file_info': 'os/modules/testutil/tu_case_append_file_info.md'
- - 'tu_case_append_manual_pass_msg': 'os/modules/testutil/tu_case_append_manual_pass_msg.md'
- - 'tu_case_complete': 'os/modules/testutil/tu_case_complete.md'
- - 'tu_case_fail_assert': 'os/modules/testutil/tu_case_fail_assert.md'
- - 'tu_case_init': 'os/modules/testutil/tu_case_init.md'
- - 'tu_case_pass_manual': 'os/modules/testutil/tu_case_pass_manual.md'
- - 'tu_case_set_name': 'os/modules/testutil/tu_case_set_name.md'
- - 'tu_case_vappend_buf': 'os/modules/testutil/tu_case_vappend_buf.md'
- - 'tu_case_write_fail_buf': 'os/modules/testutil/tu_case_write_fail_buf.md'
- - 'tu_case_write_pass_auto': 'os/modules/testutil/tu_case_write_pass_auto.md'
- - 'tu_case_write_pass_buf': 'os/modules/testutil/tu_case_write_pass_buf.md'
+ - 'Functions/Macros':
- 'tu_init': 'os/modules/testutil/tu_init.md'
+ - 'TEST_ASSERT': 'os/modules/testutil/test_assert.md'
+ - 'TEST_PASS': 'os/modules/testutil/test_pass.md'
+ - 'TEST_SUITE': 'os/modules/testutil/test_suite.md'
+ - 'TEST_CASE': 'os/modules/testutil/test_case.md'
- 'tu_restart': 'os/modules/testutil/tu_restart.md'
- - 'tu_suite_init': 'os/modules/testutil/tu_suite_init.md'
- - 'tu_suite_set_name': 'os/modules/testutil/tu_suite_set_name.md'
- Image Manager:
- 'Overview': 'os/modules/imgmgr/imgmgr.md'
- 'Functions':