diff mbox

[RFC,02/10] core/test: use strcmp for console tests

Message ID 1482298544-8418-3-git-send-email-oohall@gmail.com
State Accepted
Headers show

Commit Message

Oliver O'Halloran Dec. 21, 2016, 5:35 a.m. UTC
The console logging tests use a memcmp and strlen() with string literal
arguments. Unfortunately the strings were updated at some point and not
kept in sync. strcmp() should be fine here so use that instead.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 core/test/run-console-log-pr_fmt.c | 6 +++---
 core/test/run-console-log.c        | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Stewart Smith March 7, 2017, 6:45 a.m. UTC | #1
Oliver O'Halloran <oohall@gmail.com> writes:
> The console logging tests use a memcmp and strlen() with string literal
> arguments. Unfortunately the strings were updated at some point and not
> kept in sync. strcmp() should be fine here so use that instead.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  core/test/run-console-log-pr_fmt.c | 6 +++---
>  core/test/run-console-log.c        | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)

Sooo... I know this *technically* has RFC in the title, but it's a good
ptach and I can probably only blame myself for this.

So, merged to master as of 0cdfe0b14780152ebec39f21cf99f37d4330843d
diff mbox

Patch

diff --git a/core/test/run-console-log-pr_fmt.c b/core/test/run-console-log-pr_fmt.c
index 03ee476f5265..ae9d206cb626 100644
--- a/core/test/run-console-log-pr_fmt.c
+++ b/core/test/run-console-log-pr_fmt.c
@@ -52,7 +52,7 @@  int main(void)
 	debug_descriptor.console_log_levels = 0x75;
 
 	prlog(PR_EMERG, "Hello World");
-	assert(memcmp(console_buffer, "[    0.000000042,0] PREFIX: Hello World", strlen("[    0.000042,0] PREFIX: Hello World")) == 0);
+	assert(strcmp(console_buffer, "[    0.000000042,0] PREFIX: Hello World") == 0);
 	assert(flushed_to_drivers==true);
 
 	memset(console_buffer, 0, sizeof(console_buffer));
@@ -63,11 +63,11 @@  int main(void)
 
 	// Should not be flushed to console
 	prlog(PR_DEBUG, "Hello World");
-	assert(memcmp(console_buffer, "[    0.000000042,7] PREFIX: Hello World", strlen("[    0.000042,7] PREFIX: Hello World")) == 0);
+	assert(strcmp(console_buffer, "[    0.000000042,7] PREFIX: Hello World") == 0);
 	assert(flushed_to_drivers==false);
 
 	printf("Hello World");
-	assert(memcmp(console_buffer, "[    0.000000042,5] PREFIX: Hello World", strlen("[    0.000042,5] PREFIX: Hello World")) == 0);
+	assert(strcmp(console_buffer, "[    0.000000042,5] PREFIX: Hello World") == 0);
 	assert(flushed_to_drivers==true);
 
 	return 0;
diff --git a/core/test/run-console-log.c b/core/test/run-console-log.c
index 6d6d366b2140..01376eee7334 100644
--- a/core/test/run-console-log.c
+++ b/core/test/run-console-log.c
@@ -52,7 +52,7 @@  int main(void)
 	debug_descriptor.console_log_levels = 0x75;
 
 	prlog(PR_EMERG, "Hello World");
-	assert(memcmp(console_buffer, "[    0.000000042,0] Hello World", strlen("[    0.000042,0] Hello World")) == 0);
+	assert(strcmp(console_buffer, "[    0.000000042,0] Hello World") == 0);
 	assert(flushed_to_drivers==true);
 
 	memset(console_buffer, 0, sizeof(console_buffer));
@@ -63,11 +63,11 @@  int main(void)
 
 	// Should not be flushed to console
 	prlog(PR_DEBUG, "Hello World");
-	assert(memcmp(console_buffer, "[    0.000000042,7] Hello World", strlen("[    0.000042,7] Hello World")) == 0);
+	assert(strcmp(console_buffer, "[    0.000000042,7] Hello World") == 0);
 	assert(flushed_to_drivers==false);
 
 	printf("Hello World");
-	assert(memcmp(console_buffer, "[    0.000000042,5] Hello World", strlen("[    0.000042,5] Hello World")) == 0);
+	assert(strcmp(console_buffer, "[    0.000000042,5] Hello World") == 0);
 	assert(flushed_to_drivers==true);
 
 	return 0;