X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=tests%2Ftest_sessions.c;h=2adf233256eacfd57e568bd0cc3a60d0d744e5d7;hb=07004d4d4d41006536be911aa557fb69b87b4820;hp=5b17e63911eeb8c45fdd05723978d79eae209313;hpb=bcf480b0bf3570a23ed61207c7d8987e0c9f64cb;p=lttng-tools.git diff --git a/tests/test_sessions.c b/tests/test_sessions.c index 5b17e6391..2adf23325 100644 --- a/tests/test_sessions.c +++ b/tests/test_sessions.c @@ -26,9 +26,9 @@ #include #include -#include +#include +#include -#include #include "utils.h" #define SESSION1 "test1" @@ -37,6 +37,7 @@ #define PATH1 "/tmp/.test-junk-lttng" #define MAX_SESSIONS 10000 +#define RANDOM_STRING_LEN 11 /* * String of 263 caracters. NAME_MAX + "OVERFLOW". If OVERFLOW appears in the @@ -61,22 +62,23 @@ static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; +static char random_string[RANDOM_STRING_LEN]; /* * Return random string of 10 characters. + * Not thread-safe. */ static char *get_random_string(void) { int i; - char *str = malloc(11); - for (i = 0; i < 10; i++) { - str[i] = alphanum[rand() % (sizeof(alphanum) - 1)]; + for (i = 0; i < RANDOM_STRING_LEN - 1; i++) { + random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)]; } - str[10] = '\0'; + random_string[RANDOM_STRING_LEN - 1] = '\0'; - return str; + return random_string; } /* @@ -311,13 +313,11 @@ int main(int argc, char **argv) printf("Creating %d sessions: ", MAX_SESSIONS); fflush(stdout); for (i = 0; i < MAX_SESSIONS; i++) { - tmp_name = get_random_string(); - ret = create_one_session(tmp_name, PATH1); + ret = create_one_session(get_random_string(), PATH1); if (ret < 0) { printf("session %d (name: %s) creation failed\n", i, tmp_name); return -1; } - free(tmp_name); } PRINT_OK();