summaryrefslogtreecommitdiff
path: root/stacks/max25-bcpr/tests/test_config_offline.c
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-07 18:25:13 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-07 18:25:13 +0000
commit04d965d67a7264a1c7c211494aebda1953df7603 (patch)
tree0ebd700a6e219f84a26a656f4bee8778bc75da7b /stacks/max25-bcpr/tests/test_config_offline.c
Initial push
Diffstat (limited to 'stacks/max25-bcpr/tests/test_config_offline.c')
-rw-r--r--stacks/max25-bcpr/tests/test_config_offline.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/stacks/max25-bcpr/tests/test_config_offline.c b/stacks/max25-bcpr/tests/test_config_offline.c
new file mode 100644
index 0000000..8b40a6a
--- /dev/null
+++ b/stacks/max25-bcpr/tests/test_config_offline.c
@@ -0,0 +1,53 @@
+/*
+ * Offline config parse test — no UART.
+ */
+#include "bcpr/bcpr_config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(void)
+{
+ const char *path = "share/max25-bcpr.ini.example";
+ bcpr_config_t cfg;
+ char cwd[512];
+
+ if (!getcwd(cwd, sizeof(cwd))) {
+ return 1;
+ }
+ /* Prefer path relative to build or source. */
+ if (access(path, R_OK) != 0) {
+ path = "../share/max25-bcpr.ini.example";
+ }
+ if (access(path, R_OK) != 0) {
+ path = "../../stacks/max25-bcpr/share/max25-bcpr.ini.example";
+ }
+ if (bcpr_config_load(&cfg, path) != 0) {
+ /* Write a minimal temp INI. */
+ FILE *f = fopen("/tmp/max25-bcpr-test.ini", "w");
+ if (!f) {
+ return 1;
+ }
+ fputs("[max25-bcpr]\ndry_run = yes\nstate_dir = /tmp/max25-bcpr\n"
+ "[bc0]\nserial = /dev/ttyS0\niobase = 0x3f8\nirq = 4\n"
+ "mode = ser12*\nkiss_link = /tmp/max25-bcpr/kiss-bc0\n",
+ f);
+ fclose(f);
+ path = "/tmp/max25-bcpr-test.ini";
+ if (bcpr_config_load(&cfg, path) != 0) {
+ fprintf(stderr, "FAIL: load\n");
+ return 1;
+ }
+ }
+ if (cfg.n_dev < 1 || !cfg.dev[0].enabled) {
+ fprintf(stderr, "FAIL: no bc0\n");
+ return 1;
+ }
+ if (cfg.dev[0].irq != 4 || cfg.dev[0].iobase != 0x3f8) {
+ fprintf(stderr, "FAIL: irq/iobase\n");
+ return 1;
+ }
+ puts("OK: test_config_offline");
+ return 0;
+}
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com