summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-02-03 15:23:28 +0000
committerBenny Prijono <bennylp@teluu.com>2006-02-03 15:23:28 +0000
commit253169056aadb92e7ad4b86b92282e7bcb3a25dd (patch)
tree2430f7ec573f0a10d07b78bb88dfc494b8e05592
parent45a727c95876002e3b7468428e53ad9531f4e1a2 (diff)
Added gcov-report build target and fixed bug in string test under gcov
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@136 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--build/rules.mak5
-rw-r--r--pjlib/build/Makefile4
-rw-r--r--pjlib/src/pjlib-test/string.c43
3 files changed, 42 insertions, 10 deletions
diff --git a/build/rules.mak b/build/rules.mak
index 351a1680..2076a9bd 100644
--- a/build/rules.mak
+++ b/build/rules.mak
@@ -137,6 +137,11 @@ ifeq ($(OS_NAME),linux-kernel)
rm -f ../lib/$(app).o
endif
+gcov-report:
+ for file in $(FULL_SRCS); do \
+ gcov $$file -n -o $(OBJDIR); \
+ done
+
realclean: clean
$(subst @@,$(subst /,$(HOST_PSEP),$(LIB)) $(subst /,$(HOST_PSEP),$(EXE)),$(HOST_RM))
$(subst @@,$(DEP_FILE),$(HOST_RM))
diff --git a/pjlib/build/Makefile b/pjlib/build/Makefile
index 09777541..c278f752 100644
--- a/pjlib/build/Makefile
+++ b/pjlib/build/Makefile
@@ -99,3 +99,7 @@ realclean:
distclean: realclean
+gcov-report:
+ $(MAKE) -f $(RULES_MAK) APP=PJLIB app=pjlib gcov-report
+ $(MAKE) -f $(RULES_MAK) APP=TEST app=pjlib-test gcov-report
+
diff --git a/pjlib/src/pjlib-test/string.c b/pjlib/src/pjlib-test/string.c
index 80b3853a..713552c7 100644
--- a/pjlib/src/pjlib-test/string.c
+++ b/pjlib/src/pjlib-test/string.c
@@ -22,6 +22,8 @@
#include <pj/os.h>
#include "test.h"
+#define THIS_FILE "string.c"
+
/**
* \page page_pjlib_string_test Test: String
*
@@ -64,6 +66,27 @@
#define JUST_HELLO "Hello"
#define UL_VALUE 3456789012UL
+#if 1
+/* See if both integers have the same sign */
+PJ_INLINE(int) cmp(const char *expr, int i, int j)
+{
+ i = !((i>0 && j>0) || (i<0 && j<0) || (i==0 && j==0));
+ if (i) {
+ PJ_LOG(3,(THIS_FILE," error: %s: expecting %d, got %d", expr, j, i));
+ }
+ return i;
+}
+#else
+/* For strict comparison, must be equal */
+PJ_INLINE(int) cmp(const char *expr, int i, int j)
+{
+ PJ_UNUSED_ARG(expr);
+ return i!=j;
+}
+#endif
+
+#define C(expr, res) cmp(#expr, expr, res)
+
static int stricmp_test(void)
{
/* This specificly tests and benchmark pj_stricmp(), pj_stricmp_alnum().
@@ -75,18 +98,18 @@ static int stricmp_test(void)
s1.ptr=S1; s1.slen=S1?len:0; \
s2.ptr=S2; s2.slen=S2?len:0; \
pj_get_timestamp(&t1); \
- if (pj_stricmp(&s1,&s2)!=res) return code; \
+ if (C(pj_stricmp(&s1,&s2),res)) return code; \
pj_get_timestamp(&t2); \
pj_sub_timestamp(&t2, &t1); \
pj_add_timestamp(&e1, &t2); \
pj_get_timestamp(&t1); \
- if (pj_stricmp_alnum(&s1,&s2)!=res) return code-1; \
+ if (C(pj_stricmp_alnum(&s1,&s2),res)) return code-1; \
pj_get_timestamp(&t2); \
pj_sub_timestamp(&t2, &t1); \
pj_add_timestamp(&e2, &t2); \
- if (pj_stricmp2(&s1,S2)!=res) return code*10; \
- if (pj_strnicmp(&s1,&s2,len)!=res) return code*100; \
- if (pj_strnicmp2(&s1,S2,len)!=res) return code*1000; \
+ if (C(pj_stricmp2(&s1,S2),res)) return code*10; \
+ if (C(pj_strnicmp(&s1,&s2,len),res)) return code*100; \
+ if (C(pj_strnicmp2(&s1,S2,len),res)) return code*1000; \
} while (0)
char *buf;
@@ -114,7 +137,7 @@ static int stricmp_test(void)
len=1;
STRTEST( 0, "a",buf+0,-510);
STRTEST( 0, "a",buf+1,-512);
- STRTEST( -1, "0", "P", -514);
+ STRTEST( -1, "O", "P", -514);
STRTEST(-1, NULL, "a", -516);
STRTEST(1, "a", NULL, -518);
@@ -227,10 +250,10 @@ static int strcmp_test(void)
do { \
s1.ptr=S1; s1.slen=S1?len:0; \
s2.ptr=S2; s2.slen=S2?len:0; \
- if (pj_strcmp(&s1,&s2)!=res) return code; \
- if (pj_strcmp2(&s1,S2)!=res) return code-1; \
- if (pj_strncmp(&s1,&s2,len)!=res) return code-2; \
- if (pj_strncmp2(&s1,S2,len)!=res) return code-3; \
+ if (C(pj_strcmp(&s1,&s2),res)) return code; \
+ if (C(pj_strcmp2(&s1,S2),res)) return code-1; \
+ if (C(pj_strncmp(&s1,&s2,len),res)) return code-2; \
+ if (C(pj_strncmp2(&s1,S2,len),res)) return code-3; \
} while (0)
pj_str_t s1, s2;