[meta][kirkstone][PATCH] json-c: Add ptest

pawan
2023-04-03T16:27:35Z

From: Anuj Chougule <Anuj.Chougule@kpit.com>

Re-used implicit test suite and converted it into ptest.

Signed-off-by: pawan <badganchipv@gmail.com>
---
meta/recipes-devtools/json-c/json-c/run-ptest | 14 +++++++++++++
meta/recipes-devtools/json-c/json-c_0.15.bb | 21 ++++++++++++++++---
2 files changed, 32 insertions(+), 3 deletions(-)
create mode 100644 meta/recipes-devtools/json-c/json-c/run-ptest

diff --git a/meta/recipes-devtools/json-c/json-c/run-ptest b/meta/recipes-devtools/json-c/json-c/run-ptest
new file mode 100644
index 0000000000..570aac4588
--- /dev/null
+++ b/meta/recipes-devtools/json-c/json-c/run-ptest
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -eux
+cd tests
+for t in test1 test2 test4
+do
+ echo "Running $t.test..."
+ if "./$t.test"
+ then
+ echo "PASS:$t"
+ else
+ echo "FAIL:$t"
+ fi
+done
diff --git a/meta/recipes-devtools/json-c/json-c_0.15.bb b/meta/recipes-devtools/json-c/json-c_0.15.bb
index a4673a2f0e..4070078089 100644
--- a/meta/recipes-devtools/json-c/json-c_0.15.bb
+++ b/meta/recipes-devtools/json-c/json-c_0.15.bb
@@ -4,8 +4,9 @@ HOMEPAGE = "https://github.com/json-c/json-c/wiki"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://COPYING;md5=de54b60fbbc35123ba193fea8ee216f2"

-SRC_URI = "https://s3.amazonaws.com/json-c_releases/releases/${BP}.tar.gz"
-
+SRC_URI = "https://s3.amazonaws.com/json-c_releases/releases/${BP}.tar.gz \
+ file://run-ptest \
+ "
SRC_URI[sha256sum] = "b8d80a1ddb718b3ba7492916237bbf86609e9709fb007e7f7d4322f02341a4c6"

UPSTREAM_CHECK_URI = "https://github.com/${BPN}/${BPN}/tags"
@@ -13,6 +14,20 @@ UPSTREAM_CHECK_REGEX = "json-c-(?P<pver>\d+(\.\d+)+)-\d+"

RPROVIDES:${PN} = "libjson"

-inherit cmake
+inherit cmake ptest

BBCLASSEXTEND = "native nativesdk"
+
+RDEPENDS_${PN}-ptest += "bash"
+
+do_compile_ptest() {
+ oe_runmake -C tests test1 test2 test4
+}
+
+do_install_ptest() {
+ mkdir "${D}${PTEST_PATH}/tests"
+ for t in test1 test2 test4; do
+ cp "${S}/tests/$t"* "${D}${PTEST_PATH}/tests/"
+ done
+ cp "${S}/tests/test-defs.sh" "${D}${PTEST_PATH}/tests/"
+}
--
2.38.1