diff options
Diffstat (limited to 'tests/mysql_client_test.c')
-rw-r--r-- | tests/mysql_client_test.c | 154 |
1 files changed, 87 insertions, 67 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 6b0092e3880..534f7a51e05 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -83,6 +83,7 @@ struct my_tests_st }; #define myheader(str) \ +DBUG_PRINT("test", ("name: %s", str)); \ if (opt_silent < 2) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ @@ -90,7 +91,9 @@ if (opt_silent < 2) \ opt_count, str); \ fprintf(stdout, " \n#####################################\n"); \ } + #define myheader_r(str) \ +DBUG_PRINT("test", ("name: %s", str)); \ if (!opt_silent) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ @@ -298,7 +301,7 @@ static void client_connect(ulong flag) mysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); /* set AUTOCOMMIT to ON*/ mysql_autocommit(mysql, TRUE); @@ -321,7 +324,7 @@ static void client_connect(ulong flag) have_innodb= check_have_innodb(mysql); if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); } @@ -341,12 +344,13 @@ static void client_disconnect() mysql_query(mysql, query); if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); if (!opt_silent) fprintf(stdout, "\n closing the connection ..."); mysql_close(mysql); - fprintf(stdout, " OK\n"); + if (!opt_silent) + fprintf(stdout, "OK\n"); } } @@ -2498,7 +2502,7 @@ static void test_ps_query_cache() exit(1); } if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); mysql= lmysql; } @@ -4940,7 +4944,7 @@ static void test_stmt_close() } lmysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); /* set AUTOCOMMIT to ON*/ @@ -7471,7 +7475,7 @@ static void test_prepare_grant() } lmysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO test_grant VALUES(NULL)"); @@ -7932,7 +7936,7 @@ static void test_drop_temp() } lmysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO t1 VALUES(10, 'C')"); @@ -12018,16 +12022,24 @@ static void test_bug5315() stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); DIE_UNLESS(rc == 0); + if (!opt_silent) + printf("Excuting mysql_change_user\n"); mysql_change_user(mysql, opt_user, opt_password, current_db); + if (!opt_silent) + printf("Excuting mysql_stmt_execute\n"); rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc != 0); if (rc) { if (!opt_silent) - printf("Got error (as expected):\n%s", mysql_stmt_error(stmt)); + printf("Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); } /* check that connection is OK */ + if (!opt_silent) + printf("Excuting mysql_stmt_close\n"); mysql_stmt_close(stmt); + if (!opt_silent) + printf("Excuting mysql_stmt_init\n"); stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); DIE_UNLESS(rc == 0); @@ -12716,6 +12728,7 @@ static void test_rewind(void) /* retreive all result sets till we are at the end */ while(!mysql_stmt_fetch(stmt)) + if (!opt_silent) printf("fetched result:%ld\n", Data); DIE_UNLESS(rc != MYSQL_NO_DATA); @@ -12726,6 +12739,7 @@ static void test_rewind(void) /* now we should be able to fetch the results again */ /* but mysql_stmt_fetch returns MYSQL_NO_DATA */ while(!(rc= mysql_stmt_fetch(stmt))) + if (!opt_silent) printf("fetched result after seek:%ld\n", Data); DIE_UNLESS(rc == MYSQL_NO_DATA); @@ -13276,7 +13290,7 @@ static void test_bug8378() exit(1); } if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); len= mysql_real_escape_string(mysql, out, TEST_BUG8378_IN, 4); @@ -13445,7 +13459,8 @@ static void test_bug9520() DIE_UNLESS(rc == MYSQL_NO_DATA); - printf("Fetched %d rows\n", row_count); + if (!opt_silent) + printf("Fetched %d rows\n", row_count); DBUG_ASSERT(row_count == 3); mysql_stmt_close(stmt); @@ -15345,8 +15360,28 @@ static void test_bug17667() myheader("test_bug17667"); + master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1); + strxmov(master_log_filename, opt_vardir, "/log/master.log", NullS); + if (!opt_silent) + printf("Opening '%s'\n", master_log_filename); + log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(0)); + free(master_log_filename); + + if (log_file == NULL) + { + if (!opt_silent) + { + printf("Could not find the log file, VARDIR/log/master.log, so " + "test_bug17667 is not run.\n" + "Run test from the mysql-test/mysql-test-run* program to set up " + "correct environment for this test.\n\n"); + } + return; + } + for (statement_cursor= statements; statement_cursor->buffer != NULL; - statement_cursor++) { + statement_cursor++) + { if (statement_cursor->qt == QT_NORMAL) { /* Run statement as normal query */ @@ -15357,10 +15392,10 @@ static void test_bug17667() else if (statement_cursor->qt == QT_PREPARED) { /* - Run as prepared statement + Run as prepared statement - NOTE! All these queries should be in the log twice, - one time for prepare and one time for execute + NOTE! All these queries should be in the log twice, + one time for prepare and one time for execute */ stmt= mysql_stmt_init(mysql); @@ -15383,66 +15418,49 @@ static void test_bug17667() 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); - strcat(master_log_filename, "/log/master.log"); - printf("Opening '%s'\n", master_log_filename); - log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(MY_WME)); - free(master_log_filename); + for (statement_cursor= statements; statement_cursor->buffer != NULL; + statement_cursor++) + { + int expected_hits= 1, hits= 0; + char line_buffer[MAX_TEST_QUERY_LENGTH*2]; + /* more than enough room for the query and some marginalia. */ - if (log_file != NULL) { + /* Prepared statments always occurs twice in log */ + if (statement_cursor->qt == QT_PREPARED) + expected_hits++; - for (statement_cursor= statements; statement_cursor->buffer != NULL; - statement_cursor++) { - int expected_hits= 1, hits= 0; - char line_buffer[MAX_TEST_QUERY_LENGTH*2]; - /* more than enough room for the query and some marginalia. */ + /* Loop until we found expected number of log entries */ + do { + /* Loop until statement is found in log */ + do { + memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); - /* Prepared statments always occurs twice in log */ - if (statement_cursor->qt == QT_PREPARED) - expected_hits++; + 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"); - /* Loop until we found expected number of log entries */ - do { - /* Loop until statement is found in log */ - do { - memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); - - 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"); - - 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); - hits++; - } while (hits < expected_hits); + 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); + hits++; + } while (hits < expected_hits); + if (!opt_silent) printf("Found statement starting with \"%s\"\n", statement_cursor->buffer); - } - - printf("success. All queries found intact in the log.\n"); - - } - else - { - fprintf(stderr, "Could not find the log file, VARDIR/log/master.log, so " - "test_bug17667 is \ninconclusive. Run test from the " - "mysql-test/mysql-test-run* program \nto set up the correct " - "environment for this test.\n\n"); } - if (log_file != NULL) - my_fclose(log_file, MYF(0)); + if (!opt_silent) + printf("success. All queries found intact in the log.\n"); + my_fclose(log_file, MYF(0)); } @@ -16008,12 +16026,14 @@ static void test_bug21635() for (i= 0; i < field_count; ++i) { field= mysql_fetch_field_direct(result, i); - printf("%s -> %s ... ", expr[i * 2], field->name); + if (!opt_silent) + printf("%s -> %s ... ", expr[i * 2], field->name); fflush(stdout); DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 && field->table[0] == 0 && field->org_name[0] == 0); DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0); - puts("OK"); + if (!opt_silent) + puts("OK"); } mysql_free_result(result); |