summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2015-01-09 15:12:31 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-15 10:31:46 +0100
commitfd52e9e51bdfe00e035e0ab08ce9a6a5d6b7a974 (patch)
treeb33a105d41d79e2e8761e2b91ccfa5c8a345f888 /src/tests
parente2d36e6f735a1f10cb80726a4691f225e66233ed (diff)
downloadsssd-fd52e9e51bdfe00e035e0ab08ce9a6a5d6b7a974.tar.gz
sssd-fd52e9e51bdfe00e035e0ab08ce9a6a5d6b7a974.tar.xz
sssd-fd52e9e51bdfe00e035e0ab08ce9a6a5d6b7a974.zip
server-tests: use strtouint32 instead strtol
PID may be greater than 0xffff thus we remove this check but it is supposed to be in range of uint32. There are also some improvements to get more information from assertions. Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/cwrap/test_server.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/tests/cwrap/test_server.c b/src/tests/cwrap/test_server.c
index d0aeac47d..55ef2ecae 100644
--- a/src/tests/cwrap/test_server.c
+++ b/src/tests/cwrap/test_server.c
@@ -26,6 +26,7 @@
#include <popt.h>
#include "util/util.h"
+#include "util/strtonum.h"
#include "tests/cmocka/common_mock.h"
static void wait_for_fg_server(pid_t pid)
@@ -44,7 +45,7 @@ static void wait_for_fg_server(pid_t pid)
static void wait_for_bg_server(const char *pidfile)
{
int fd;
- long tmp;
+ uint32_t tmp;
char buf[16];
pid_t pid;
int ret;
@@ -74,10 +75,12 @@ static void wait_for_bg_server(const char *pidfile)
buf[sizeof(buf) - 1] = '\0';
- tmp = strtol(buf, NULL, 10);
- assert_false(tmp == 0 || tmp > 0xFFFF || errno == ERANGE);
+ errno = 0;
+ tmp = strtouint32(buf, NULL, 10);
+ assert_int_not_equal(tmp, 0);
+ assert_int_equal(errno, 0);
- pid = (pid_t) (tmp & 0xFFFF);
+ pid = (pid_t) (tmp);
/* Make sure the daemon goes away! */
ret = kill(pid, SIGTERM);