X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Ftest_sessions.c;h=e55593561891d2827ba8cb8761e188e31c1d3e92;hp=5b17e63911eeb8c45fdd05723978d79eae209313;hb=0e4cbe7e2c4c6a8343e710a3b050af8c33f95e21;hpb=bcf480b0bf3570a23ed61207c7d8987e0c9f64cb diff --git a/tests/test_sessions.c b/tests/test_sessions.c index 5b17e6391..e55593561 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 @@ -54,29 +55,30 @@ static struct ltt_session_list *session_list; /* For lttngerr.h */ -int opt_quiet = 1; -int opt_verbose = 0; +int lttng_opt_quiet = 1; +int lttng_opt_verbose = 0; 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; } /* @@ -239,7 +241,6 @@ static int two_session_same_name(void) int main(int argc, char **argv) { int ret, i; - char *tmp_name; struct ltt_session *iter, *tmp; srand(time(NULL)); @@ -311,13 +312,18 @@ 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(); + char *tmp_name = get_random_string(); + ret = create_one_session(tmp_name, PATH1); if (ret < 0) { printf("session %d (name: %s) creation failed\n", i, tmp_name); return -1; } - free(tmp_name); + + if ((i % 1000) == 0) { + fprintf(stdout, "%d..", i); + fflush(stdout); + } } PRINT_OK();