Skip to content

Commit

Permalink
Removed injected crash in uri_test. Disable stdout/stderr buffering f…
Browse files Browse the repository at this point in the history
…or unit tests
  • Loading branch information
bennylp committed Feb 5, 2025
1 parent 967b94c commit 1e11005
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pjlib/src/pjlib-test/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <pj/string.h>
#include <pj/unittest.h>

#include <stdio.h>

/* Overrideable max tests */
#ifndef UT_MAX_TESTS
# define UT_MAX_TESTS 16
Expand Down Expand Up @@ -48,6 +50,12 @@ typedef struct ut_app_t
/* Call this in main.c before parsing arguments */
PJ_INLINE(void) ut_app_init0(ut_app_t *ut_app)
{
/* Disable buffering because sometimes output is not captured/shown
* (by cirunner) if the test program crashes too soon.
*/
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);

pj_bzero(ut_app, sizeof(*ut_app));
ut_app->prm_logging_policy = PJ_TEST_FAILED_TESTS;
ut_app->prm_nthreads = -1;
Expand Down
3 changes: 0 additions & 3 deletions pjsip/src/test/uri_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,6 @@ static int simple_uri_test(void)
pj_pool_t *pool;
pj_status_t status;

i = 0;
*(int*)(long)i = 0x12345;

PJ_LOG(3,(THIS_FILE, " simple test"));
for (i=0; i<PJ_ARRAY_SIZE(uri_test_array); ++i) {
pool = pjsip_endpt_create_pool(endpt, "", POOL_SIZE, POOL_SIZE);
Expand Down

0 comments on commit 1e11005

Please sign in to comment.