summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-02-28 22:19:23 +0000
committerBenny Prijono <bennylp@teluu.com>2011-02-28 22:19:23 +0000
commit7506dc2e5de7c417ec9835bf95a29e442fa0ed37 (patch)
tree581d81ed044c2a9a2e3bdedcf2b81fc761a494f3 /pjlib
parentbecc875a5dafe43a6067b6fb5e0c953c582fad48 (diff)
Re #1202 (pjlib sysinfo): testing on OpenSolaris and added pjlib-test entry
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3426 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/src/pj/os_info.c12
-rw-r--r--pjlib/src/pjlib-test/os.c24
-rw-r--r--pjlib/src/pjlib-test/test.c4
-rw-r--r--pjlib/src/pjlib-test/test.h2
4 files changed, 40 insertions, 2 deletions
diff --git a/pjlib/src/pj/os_info.c b/pjlib/src/pj/os_info.c
index d82aea5c..a10a95ce 100644
--- a/pjlib/src/pj/os_info.c
+++ b/pjlib/src/pj/os_info.c
@@ -88,6 +88,8 @@ PJ_DEF(const pj_sys_info*) pj_get_sys_info(void)
if (si_initialized)
return &si;
+ si.machine.ptr = si.os_name.ptr = si.sdk_name.ptr = si.info.ptr = "";
+
#define ALLOC_CP_STR(str,field) \
do { \
len = pj_ansi_strlen(str); \
@@ -108,8 +110,12 @@ PJ_DEF(const pj_sys_info*) pj_get_sys_info(void)
char *tok;
int i, maxtok;
- if (uname(&u) != 0)
+ /* Successful uname() returns zero on Linux and positive value
+ * on OpenSolaris.
+ */
+ if (uname(&u) == -1)
goto get_sdk_info;
+
ALLOC_CP_STR(u.machine, machine);
ALLOC_CP_STR(u.sysname, os_name);
@@ -226,10 +232,12 @@ get_sdk_info:
int cnt;
cnt = pj_ansi_snprintf(tmp, sizeof(tmp),
- "%s%s/%s/%s%s",
+ "%s%s%s%s%s%s%s",
si.os_name.ptr,
ver_info(si.os_ver, os_ver),
+ (si.machine.slen ? "/" : ""),
si.machine.ptr,
+ (si.sdk_name.slen ? "/" : ""),
si.sdk_name.ptr,
ver_info(si.sdk_ver, sdk_ver));
if (cnt > 0 && cnt < (int)sizeof(tmp)) {
diff --git a/pjlib/src/pjlib-test/os.c b/pjlib/src/pjlib-test/os.c
index e82ac244..2a28b928 100644
--- a/pjlib/src/pjlib-test/os.c
+++ b/pjlib/src/pjlib-test/os.c
@@ -17,4 +17,28 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "test.h"
+#include <pj/log.h>
+#include <pj/os.h>
+
+#if INCLUDE_OS_TEST
+int os_test(void)
+{
+ const pj_sys_info *si;
+ int rc = 0;
+
+ si = pj_get_sys_info();
+ PJ_LOG(3,("", " machine: %s", si->machine.ptr));
+ PJ_LOG(3,("", " os_name: %s", si->os_name.ptr));
+ PJ_LOG(3,("", " os_ver: 0x%x", si->os_ver));
+ PJ_LOG(3,("", " sdk_name: %s", si->sdk_name.ptr));
+ PJ_LOG(3,("", " sdk_ver: 0x%x", si->sdk_ver));
+ PJ_LOG(3,("", " info: %s", si->info.ptr));
+
+ return rc;
+}
+
+#else
int dummy_os_var;
+#endif
+
diff --git a/pjlib/src/pjlib-test/test.c b/pjlib/src/pjlib-test/test.c
index 9d7c1ba4..7983284b 100644
--- a/pjlib/src/pjlib-test/test.c
+++ b/pjlib/src/pjlib-test/test.c
@@ -75,6 +75,10 @@ int test_inner(void)
DO_TEST( exception_test() );
#endif
+#if INCLUDE_OS_TEST
+ DO_TEST( os_test() );
+#endif
+
#if INCLUDE_RAND_TEST
DO_TEST( rand_test() );
#endif
diff --git a/pjlib/src/pjlib-test/test.h b/pjlib/src/pjlib-test/test.h
index 2d65d15d..d33a9ba7 100644
--- a/pjlib/src/pjlib-test/test.h
+++ b/pjlib/src/pjlib-test/test.h
@@ -47,6 +47,7 @@
#define INCLUDE_ATOMIC_TEST GROUP_OS
#define INCLUDE_MUTEX_TEST (PJ_HAS_THREADS && GROUP_OS)
#define INCLUDE_SLEEP_TEST GROUP_OS
+#define INCLUDE_OS_TEST GROUP_OS
#define INCLUDE_THREAD_TEST (PJ_HAS_THREADS && GROUP_OS)
#define INCLUDE_SOCK_TEST GROUP_NETWORK
#define INCLUDE_SOCK_PERF_TEST GROUP_NETWORK
@@ -78,6 +79,7 @@ extern int exception_test(void);
extern int rand_test(void);
extern int list_test(void);
extern int hash_test(void);
+extern int os_test(void);
extern int pool_test(void);
extern int pool_perf_test(void);
extern int string_test(void);