From 2e4dbadf9f7364ac1fa38a2850fd0d4b6cffc882 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 7 Aug 2006 10:16:37 +0200 Subject: [PATCH 1/4] fflush(NULL) before abort so that all pending writes are performed --- tests/mysql_client_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index b65528eccb6..7cdd82f3779 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -122,7 +122,7 @@ static void client_disconnect(); void die(const char *file, int line, const char *expr) { fprintf(stderr, "%s:%d: check failed: '%s'\n", file, line, expr); - fflush(stderr); + fflush(NULL); abort(); } From 68168c8e8fa9dc63732dce14a5aeae56fd8061eb Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 7 Aug 2006 11:29:41 +0200 Subject: [PATCH 2/4] Change the 'sleep' into an explicit FLUSH LOGS command --- tests/mysql_client_test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 7cdd82f3779..89b07143873 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -14930,7 +14930,9 @@ static void test_bug17667() myquery(rc); } - sleep(1); /* The server may need time to flush the data to the log. */ + /* Make sure the server has written the logs to disk before reading it */ + rc= mysql_query(mysql, "flush logs"); + myquery(rc); master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1); strcpy(master_log_filename, opt_vardir); From 419e4dd46f0be456144f00388e4543341e9ebd2f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 7 Aug 2006 14:02:57 +0200 Subject: [PATCH 3/4] Add printouts in test case for bug17667 --- tests/mysql_client_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 89b07143873..f5acf179319 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -14937,6 +14937,7 @@ static void test_bug17667() master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1); strcpy(master_log_filename, opt_vardir); strcat(master_log_filename, "/log/master.log"); + printf("Opening '%s'\n", master_log_filename); log_file= fopen(master_log_filename, "r"); free(master_log_filename); @@ -14956,6 +14957,9 @@ static void test_bug17667() } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, statement_cursor->buffer, statement_cursor->length) == NULL); + + printf("Found statement starting with \"%s\"\n", + statement_cursor->buffer); } printf("success. All queries found intact in the log.\n"); From 862d5626a5b7d2bcf9dbbf76d250e0130844989f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 7 Aug 2006 17:26:02 +0200 Subject: [PATCH 4/4] Add some more code to analyze why the fgets fails. --- tests/mysql_client_test.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index f5acf179319..32a8e94aee9 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -14951,9 +14951,18 @@ static void test_bug17667() do { memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); - DIE_UNLESS(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) != - NULL); - /* If we reach EOF before finishing the statement list, then we failed. */ + if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL) + { + /* If fgets returned NULL, it indicates either error or EOF */ + if (feof(log_file)) + DIE("Found EOF before all statements where found"); + else + { + fprintf(stderr, "Got error %d while reading from file\n", + ferror(log_file)); + DIE("Read error"); + } + } } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, statement_cursor->buffer, statement_cursor->length) == NULL);