Keith Whyte has uploaded this change for review. ( https://gerrit.osmocom.org/14140
Change subject: tests: Mute stdout during db_prepare() ...................................................................... tests: Mute stdout during db_prepare() libdbi on debian unstable (at least) outputs: "no table in statement !" breaking the db_test. Redirect stdout to /dev/null and restore after the function completes. Closes OS#4016 Change-Id: I8227aa8fa44d3237019db52dd0825f827797261b --- M openbsc/tests/db/db_test.c 1 file changed, 21 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/40/14140/1 diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c index 755a6e9..5167185 100644 --- a/openbsc/tests/db/db_test.c +++ b/openbsc/tests/db/db_test.c @@ -30,6 +30,7 @@ #include <stdlib.h> #include <stdbool.h> #include <inttypes.h> +#include <unistd.h> static struct gsm_network dummy_net; static struct gsm_subscriber_group dummy_sgrp; @@ -208,6 +209,8 @@ dummy_net.subscr_group = &dummy_sgrp; dummy_sgrp.net = &dummy_net; + int rc; + fpos_t pos; if (db_init("hlr.sqlite3")) { printf("DB: Failed to init database. Please check the option settings.\n"); @@ -215,10 +218,27 @@ } printf("DB: Database initialized.\n"); - if (db_prepare()) { + /* Muting stdout here because libdbi + * may output noise on some platforms */ + + fflush(stdout); + fgetpos(stdout, &pos); + int old_stdout = dup(fileno(stdout)); + freopen("/dev/null", "w", stdout); + + rc = db_prepare(); + + fflush(stdout); + dup2(old_stdout, fileno(stdout)); + close(old_stdout); + clearerr(stdout); + fsetpos(stdout, &pos); + + if (rc) { printf("DB: Failed to prepare database.\n"); return 1; } + printf("DB: Database prepared.\n"); struct gsm_subscriber *alice = NULL; -- To view, visit https://gerrit.osmocom.org/14140 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I8227aa8fa44d3237019db52dd0825f827797261b Gerrit-Change-Number: 14140 Gerrit-PatchSet: 1 Gerrit-Owner: Keith Whyte <ke...@rhizomatica.org>