From 9d96d396ec4db0ae4166d29bc081ba37a0d6e5fe Mon Sep 17 00:00:00 2001 From: Michael Nosthoff Date: Fri, 2 Oct 2026 09:56:30 +0200 Subject: [PATCH] support/testing: sqlitecpp: new runtime test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build and run an SQLiteCpp example to check database writes and queries. Assisted-by: GitHub Copilot:GPT-6 Sol Signed-off-by: Michael Nosthoff Signed-off-by: Thomas Petazzoni (cherry picked from commit 93c6c91955de390f435de6e484b0b06f46e97128) Signed-off-by: Raphaël Mélotte --- DEVELOPERS | 2 ++ .../package/br2-external/sqlitecpp/Config.in | 1 + .../br2-external/sqlitecpp/external.desc | 1 + .../br2-external/sqlitecpp/external.mk | 1 + .../package/sqlitecpp-test/Config.in | 5 ++++ .../package/sqlitecpp-test/sqlitecpp-test.cpp | 27 +++++++++++++++++++ .../package/sqlitecpp-test/sqlitecpp-test.mk | 19 +++++++++++++ .../testing/tests/package/test_sqlitecpp.py | 25 +++++++++++++++++ 8 files changed, 81 insertions(+) create mode 100644 support/testing/tests/package/br2-external/sqlitecpp/Config.in create mode 100644 support/testing/tests/package/br2-external/sqlitecpp/external.desc create mode 100644 support/testing/tests/package/br2-external/sqlitecpp/external.mk create mode 100644 support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/Config.in create mode 100644 support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.cpp create mode 100644 support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.mk create mode 100644 support/testing/tests/package/test_sqlitecpp.py diff --git a/DEVELOPERS b/DEVELOPERS index c63c855997..baba0dc4bb 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -2459,6 +2459,8 @@ F: package/protobuf/ F: package/sdbus-cpp/ F: package/spdlog/ F: package/sqlitecpp/ +F: support/testing/tests/package/br2-external/sqlitecpp/ +F: support/testing/tests/package/test_sqlitecpp.py N: Michael Trimarchi F: board/bsh/ diff --git a/support/testing/tests/package/br2-external/sqlitecpp/Config.in b/support/testing/tests/package/br2-external/sqlitecpp/Config.in new file mode 100644 index 0000000000..040dfde871 --- /dev/null +++ b/support/testing/tests/package/br2-external/sqlitecpp/Config.in @@ -0,0 +1 @@ +source "$BR2_EXTERNAL_SQLITECPP_PATH/package/sqlitecpp-test/Config.in" diff --git a/support/testing/tests/package/br2-external/sqlitecpp/external.desc b/support/testing/tests/package/br2-external/sqlitecpp/external.desc new file mode 100644 index 0000000000..d11d7db86a --- /dev/null +++ b/support/testing/tests/package/br2-external/sqlitecpp/external.desc @@ -0,0 +1 @@ +name: SQLITECPP diff --git a/support/testing/tests/package/br2-external/sqlitecpp/external.mk b/support/testing/tests/package/br2-external/sqlitecpp/external.mk new file mode 100644 index 0000000000..17ed34592b --- /dev/null +++ b/support/testing/tests/package/br2-external/sqlitecpp/external.mk @@ -0,0 +1 @@ +include $(sort $(wildcard $(BR2_EXTERNAL_SQLITECPP_PATH)/package/*/*.mk)) diff --git a/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/Config.in b/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/Config.in new file mode 100644 index 0000000000..c02db0a304 --- /dev/null +++ b/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/Config.in @@ -0,0 +1,5 @@ +config BR2_PACKAGE_SQLITECPP_TEST + bool "sqlitecpp-test" + depends on BR2_PACKAGE_SQLITECPP + help + Test program for the SQLiteCpp library. diff --git a/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.cpp b/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.cpp new file mode 100644 index 0000000000..c1f2b41dba --- /dev/null +++ b/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.cpp @@ -0,0 +1,27 @@ +#include + +#include +#include + +int main() +{ + SQLite::Database db(":memory:", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE); + db.exec("CREATE TABLE fruits (name TEXT, color TEXT)"); + + SQLite::Statement insert(db, "INSERT INTO fruits VALUES (?, ?)"); + insert.bind(1, "Banana"); + insert.bind(2, "Yellow"); + insert.exec(); + + SQLite::Statement query(db, "SELECT name, color FROM fruits"); + if (!query.executeStep()) { + return 1; + } + const std::string name = query.getColumn(0).getString(); + const std::string color = query.getColumn(1).getString(); + if (name != "Banana" || color != "Yellow" || query.executeStep()) { + return 1; + } + std::cout << name << ": " << color << std::endl; + return 0; +} diff --git a/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.mk b/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.mk new file mode 100644 index 0000000000..a0ef906f92 --- /dev/null +++ b/support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.mk @@ -0,0 +1,19 @@ +################################################################################ +# +# sqlitecpp-test +# +################################################################################ + +SQLITECPP_TEST_DEPENDENCIES = sqlitecpp + +define SQLITECPP_TEST_BUILD_CMDS + $(TARGET_CXX) $(TARGET_CXXFLAGS) -o $(@D)/sqlitecpp-test \ + $(SQLITECPP_TEST_PKGDIR)/sqlitecpp-test.cpp \ + $(TARGET_LDFLAGS) -lSQLiteCpp -lsqlite3 +endef + +define SQLITECPP_TEST_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $(@D)/sqlitecpp-test $(TARGET_DIR)/usr/bin/sqlitecpp-test +endef + +$(eval $(generic-package)) diff --git a/support/testing/tests/package/test_sqlitecpp.py b/support/testing/tests/package/test_sqlitecpp.py new file mode 100644 index 0000000000..59844d4628 --- /dev/null +++ b/support/testing/tests/package/test_sqlitecpp.py @@ -0,0 +1,25 @@ +import os + +import infra.basetest + + +class TestSQLiteCpp(infra.basetest.BRTest): + br2_external = [infra.filepath("tests/package/br2-external/sqlitecpp")] + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_PACKAGE_SQLITECPP=y + BR2_PACKAGE_SQLITECPP_TEST=y + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + output, exit_code = self.emulator.run("/usr/bin/sqlitecpp-test") + self.assertEqual(exit_code, 0, output) + self.assertIn("Banana: Yellow", output)