Skip to contentSkip to conversation

support/testing: sqlitecpp: new runtime test

PATCH Superseded Michael Nosthoff via buildroot 1 participant 4 messages Oct 1

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 support/testing: sqlitecpp: new runtime test

build and run an SQLiteCpp example to check database writes and queries.

Assisted-by GitHub Copilot:GPT-6 Sol
---
 DEVELOPERS                                    |  1 +
 .../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, 80 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
DEVELOPERS +1 -0
index d62bfaafb3..c1ec5a8253 100644
@@ -2464,6 +2464,7 @@ F:	package/protobuf/
 F:	package/sdbus-cpp/
 F:	package/spdlog/
 F:	package/sqlitecpp/
+F:	support/testing/tests/package/sqlitecpp/
 
 N:	Michael Trimarchi <[email protected]>
 F:	board/bsh/
support/testing/tests/package/br2-external/sqlitecpp/Config.in new file +1 -0
new file mode 100644
index 0000000000..586f1dfa5a
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_SQLITECPP_PATH/package/sqlitecpp-test/Config.in"
\ No newline at end of file
support/testing/tests/package/br2-external/sqlitecpp/external.desc new file +1 -0
new file mode 100644
index 0000000000..003e033127
@@ -0,0 +1 @@
+name: SQLITECPP
\ No newline at end of file
support/testing/tests/package/br2-external/sqlitecpp/external.mk new file +1 -0
new file mode 100644
index 0000000000..b5db18b281
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_SQLITECPP_PATH)/package/*/*.mk))
\ No newline at end of file
support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/Config.in new file +5 -0
new file mode 100644
index 0000000000..d83b99bad8
@@ -0,0 +1,5 @@
+config BR2_PACKAGE_SQLITECPP_TEST
+	bool "sqlitecpp-test"
+	depends on BR2_PACKAGE_SQLITECPP
+	help
+	  Test program for the SQLiteCpp library.
\ No newline at end of file
support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.cpp new file +27 -0
new file mode 100644
index 0000000000..d888a9a392
@@ -0,0 +1,27 @@
+#include <SQLiteCpp/SQLiteCpp.h>
+
+#include <iostream>
+#include <string>
+
+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;
+}
\ No newline at end of file
support/testing/tests/package/br2-external/sqlitecpp/package/sqlitecpp-test/sqlitecpp-test.mk new file +19 -0
new file mode 100644
index 0000000000..da557ad874
@@ -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))
\ No newline at end of file
support/testing/tests/package/test_sqlitecpp.py new file +25 -0
new file mode 100644
index 0000000000..59844d4628
@@ -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)
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/4 package/sqlitecpp: disable stack_protection

SQLiteCpp has an internal setting for stack protection which defaults to "on".
Since Buildroot passes this options itself this is not needed.

Fixes:
br-test-pkg/bootlin-x86-i686-musl
https://gitlab.com/heinemml/buildroot/-/jobs/16865965418

---
 package/sqlitecpp/sqlitecpp.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/sqlitecpp/sqlitecpp.mk +2 -1
index 95ddc953cb..418860fc6d 100644
@@ -14,6 +14,7 @@ SQLITECPP_INSTALL_STAGING = YES
 SQLITECPP_CONF_OPTS = \
 	-DSQLITECPP_INTERNAL_SQLITE=OFF \
 	-DSQLITECPP_RUN_CPPLINT=OFF \
-	-DSQLITECPP_RUN_CPPCHECK=OFF
+	-DSQLITECPP_RUN_CPPCHECK=OFF \
+	-DSQLITECPP_USE_STACK_PROTECTION=OFF
 
 $(eval $(cmake-package))
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH 3/4 package/sqlitecpp: needs threads

In reply to Michael Nosthoff via buildroot

SQLiteCpp has an unconditional dependency on threads.

fixes:
br-test-pkg/br-arm-full-nothread
https://gitlab.com/heinemml/buildroot/-/jobs/16865965420

---
 package/sqlitecpp/Config.in | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
package/sqlitecpp/Config.in +4 -2
index 31de9a3904..614c46cb54 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_SQLITECPP
 	bool "sqlitecpp"
 	depends on BR2_INSTALL_LIBSTDCPP
+	depends on BR2_TOOLCHAIN_HAS_THREADS
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # C++11
 	select BR2_PACKAGE_SQLITE
 	select BR2_PACKAGE_SQLITE_ENABLE_COLUMN_METADATA
@@ -10,5 +11,6 @@ config BR2_PACKAGE_SQLITECPP
 
 	  https://github.com/SRombauts/SQLiteCpp
 
-comment "sqlitecpp needs a toolchain w/ C++11, gcc >= 4.9"
-	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
+comment "sqlitecpp needs a toolchain w/ C++11, threads, gcc >= 4.9"
+	depends on !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HAS_THREADS || \
+		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH 4/4 package/sqlitecpp: bump to version 3.4.0

In reply to Michael Nosthoff via buildroot

- licenses hash changed due to updated year

changelog:
https://github.com/SRombauts/SQLiteCpp/releases/tag/3.4.0

---

Pipeline with br-test-pkg and runtime test:
https://gitlab.com/heinemml/buildroot/-/pipelines/2901349165

---
 package/sqlitecpp/sqlitecpp.hash | 4 ++--
 package/sqlitecpp/sqlitecpp.mk   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
package/sqlitecpp/sqlitecpp.hash +2 -2
index 960d9bfb21..c9de5048e5 100644
@@ -1,3 +1,3 @@
 # Locally computed:
-sha256  33bd4372d83bc43117928ee842be64d05e7807f511b5195f85d30015cad9cac6  sqlitecpp-3.3.3.tar.gz
-sha256  a16149966042207bfc968dd1081403d43a37a6264fe31c7b1a7960dbb0e716b9  LICENSE.txt
+sha256  9910ad8bc0a821856bd6d9fa7cb0b457883108f2b803700256b451077ed6dc05  sqlitecpp-3.4.0.tar.gz
+sha256  00f43691f376cc7abdab1f9d72ba9d1a92846b481d2df5ffa1c345108b28048c  LICENSE.txt
package/sqlitecpp/sqlitecpp.mk +1 -1
index 418860fc6d..9c136ed69e 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-SQLITECPP_VERSION = 3.3.3
+SQLITECPP_VERSION = 3.4.0
 SQLITECPP_SITE = $(call github,SRombauts,SQLiteCpp,$(SQLITECPP_VERSION))
 SQLITECPP_LICENSE = MIT
 SQLITECPP_LICENSE_FILES = LICENSE.txt
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot