summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2020-10-21 11:13:47 +0200
committerDamien George <damien@micropython.org>2020-10-29 15:30:42 +1100
commit25c4563f26c2270cde01b01dca0e8b801c9c8282 (patch)
tree893f7160c558bceb288f06642d2fae440d51014d /tests
parentfad4079778f46bc21dd19a674b31b4c3c7eb6a91 (diff)
downloadmicropython-25c4563f26c2270cde01b01dca0e8b801c9c8282.tar.gz
micropython-25c4563f26c2270cde01b01dca0e8b801c9c8282.zip
examples: Add example code for user C modules, both C and C++.
Add working example code to provide a starting point for users with files that they can just copy, and include the modules in the coverage test to verify the complete user C module build functionality. The cexample module uses the code originally found in cmodules.rst, which has been updated to reflect this and partially rewritten with more complete information.
Diffstat (limited to 'tests')
-rw-r--r--tests/unix/extra_coverage.py10
-rw-r--r--tests/unix/extra_coverage.py.exp2
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py
index 1c028506e3..b4808993a7 100644
--- a/tests/unix/extra_coverage.py
+++ b/tests/unix/extra_coverage.py
@@ -49,6 +49,16 @@ print(buf.write(bytearray(16)))
# function defined in C++ code
print("cpp", extra_cpp_coverage())
+# test user C module
+import cexample
+
+print(cexample.add_ints(3, 2))
+
+# test user C module mixed with C++ code
+import cppexample
+
+print(cppexample.cppfunc(1, 2))
+
# test basic import of frozen scripts
import frzstr1
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 514ff9437b..257224108a 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -145,6 +145,8 @@ OSError
None
None
cpp None
+5
+(3, 'hellocpp')
frzstr1
frzstr1.py
frzmpy1