diff mbox

[kvm-unit-tests,v2,2/6] s390x: basic self test

Message ID 20170518113427.18387-3-david@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Hildenbrand May 18, 2017, 11:34 a.m. UTC
Test if the general infrastructure is working. The test will fail until
we have proper sclp console output.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 s390x/Makefile      |  2 ++
 s390x/selftest.c    | 41 +++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg |  5 +++++
 3 files changed, 48 insertions(+)
 create mode 100644 s390x/selftest.c

Comments

Thomas Huth May 19, 2017, 9:23 a.m. UTC | #1
On 18.05.2017 13:34, David Hildenbrand wrote:
> Test if the general infrastructure is working. The test will fail until
> we have proper sclp console output.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  s390x/Makefile      |  2 ++
>  s390x/selftest.c    | 41 +++++++++++++++++++++++++++++++++++++++++
>  s390x/unittests.cfg |  5 +++++
>  3 files changed, 48 insertions(+)
>  create mode 100644 s390x/selftest.c
> 
> diff --git a/s390x/Makefile b/s390x/Makefile
> index 193c3a0..4c6f9b5 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -1,3 +1,5 @@
> +tests = $(TEST_DIR)/selftest.elf
> +
>  all: test_cases
>  
>  test_cases: $(tests)
> diff --git a/s390x/selftest.c b/s390x/selftest.c
> new file mode 100644
> index 0000000..d6d4167
> --- /dev/null
> +++ b/s390x/selftest.c
> @@ -0,0 +1,41 @@
> +/*
> + * Copyright (c) 2017 Red Hat Inc
> + *
> + * Authors:
> + *  Thomas Huth <thuth@redhat.com>
> + *  David Hildenbrand <david@redhat.com>
> + *
> + * This code is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Library General Public License version 2.
> + */
> +#include <libcflat.h>
> +#include <util.h>
> +
> +static void test_fp(void)
> +{
> +	double a = 3.0;
> +	double b = 2.0;
> +	double c;
> +
> +	asm volatile(
> +		"	ddb %1, %2\n"
> +		"	std %1, %0\n"
> +		: "=m" (c) : "f" (a), "m" (b) : );

You could omit the final ":" here.

> +
> +	report("3.0/2.0 == 1.5",	c == 1.5);

The indentation of the last parameter looks weird when only looking at
this function.

> +}
> +
> +int main(int argc, char**argv)
> +{
> +	report_prefix_push("selftest");
> +
> +	report("true",			true);
> +	report("argc == 3",		argc == 3);
> +	report("argv[0] == PROGNAME",	!strcmp(argv[0], "s390x/selftest.elf"));
> +	report("argv[1] == test",	!strcmp(argv[1], "test"));
> +	report("argv[2] == 123",	!strcmp(argv[2], "123"));

I think I'd also prefer if you could remove the indentation of the
second parameters here.
Also not sure whether we should really use the argv[1] and argv[2] test
here? ... that way, you hardly can run this test manually (without
unittests.cfg) ... I think it would be nicer if we'd had something like
in arm/selftest.c here one day ... but ok, for a start, it's likely ok.

> +	test_fp();
> +
> +	return report_summary();
> +}
> diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
> index b1e0b1e..92e01ab 100644
> --- a/s390x/unittests.cfg
> +++ b/s390x/unittests.cfg
> @@ -17,3 +17,8 @@
>  #			 # to check separated by a space but each check
>  #			 # parameter needs to be of the form <path>=<value>
>  ##############################################################################
> +
> +[selftest-setup]
> +file = selftest.elf
> +groups = selftest
> +extra_params = -append 'test 123'
> 

 Thomas
David Hildenbrand May 19, 2017, 12:45 p.m. UTC | #2
>> +	asm volatile(
>> +		"	ddb %1, %2\n"
>> +		"	std %1, %0\n"
>> +		: "=m" (c) : "f" (a), "m" (b) : );
> 
> You could omit the final ":" here.

Yes, will drop it!

> 
>> +
>> +	report("3.0/2.0 == 1.5",	c == 1.5);
> 
> The indentation of the last parameter looks weird when only looking at
> this function.
> 
>> +}
>> +
>> +int main(int argc, char**argv)
>> +{
>> +	report_prefix_push("selftest");
>> +
>> +	report("true",			true);
>> +	report("argc == 3",		argc == 3);
>> +	report("argv[0] == PROGNAME",	!strcmp(argv[0], "s390x/selftest.elf"));
>> +	report("argv[1] == test",	!strcmp(argv[1], "test"));
>> +	report("argv[2] == 123",	!strcmp(argv[2], "123"));
> 
> I think I'd also prefer if you could remove the indentation of the
> second parameters here.

Me too, added it because Radim proposed it. Will simply drop the
indentation.

> Also not sure whether we should really use the argv[1] and argv[2] test
> here? ... that way, you hardly can run this test manually (without
> unittests.cfg) ... I think it would be nicer if we'd had something like
> in arm/selftest.c here one day ... but ok, for a start, it's likely ok.

Mixed feelings, for now I think this should be fine.

Testing frameworks will run it via unittests.cfg
The handful of people that actually execute the test manually either now
about this or should be able to figure out what is going on here.

So I agree, that we could change this later, once everything has been
running fine for a while.

> 
>> +	test_fp();
>> +
>> +	return report_summary();
>> +}
>> diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
>> index b1e0b1e..92e01ab 100644
>> --- a/s390x/unittests.cfg
>> +++ b/s390x/unittests.cfg
>> @@ -17,3 +17,8 @@
>>  #			 # to check separated by a space but each check
>>  #			 # parameter needs to be of the form <path>=<value>
>>  ##############################################################################
>> +
>> +[selftest-setup]
>> +file = selftest.elf
>> +groups = selftest
>> +extra_params = -append 'test 123'
>>
> 
>  Thomas
> 

Thanks!
diff mbox

Patch

diff --git a/s390x/Makefile b/s390x/Makefile
index 193c3a0..4c6f9b5 100644
--- a/s390x/Makefile
+++ b/s390x/Makefile
@@ -1,3 +1,5 @@ 
+tests = $(TEST_DIR)/selftest.elf
+
 all: test_cases
 
 test_cases: $(tests)
diff --git a/s390x/selftest.c b/s390x/selftest.c
new file mode 100644
index 0000000..d6d4167
--- /dev/null
+++ b/s390x/selftest.c
@@ -0,0 +1,41 @@ 
+/*
+ * Copyright (c) 2017 Red Hat Inc
+ *
+ * Authors:
+ *  Thomas Huth <thuth@redhat.com>
+ *  David Hildenbrand <david@redhat.com>
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Library General Public License version 2.
+ */
+#include <libcflat.h>
+#include <util.h>
+
+static void test_fp(void)
+{
+	double a = 3.0;
+	double b = 2.0;
+	double c;
+
+	asm volatile(
+		"	ddb %1, %2\n"
+		"	std %1, %0\n"
+		: "=m" (c) : "f" (a), "m" (b) : );
+
+	report("3.0/2.0 == 1.5",	c == 1.5);
+}
+
+int main(int argc, char**argv)
+{
+	report_prefix_push("selftest");
+
+	report("true",			true);
+	report("argc == 3",		argc == 3);
+	report("argv[0] == PROGNAME",	!strcmp(argv[0], "s390x/selftest.elf"));
+	report("argv[1] == test",	!strcmp(argv[1], "test"));
+	report("argv[2] == 123",	!strcmp(argv[2], "123"));
+
+	test_fp();
+
+	return report_summary();
+}
diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
index b1e0b1e..92e01ab 100644
--- a/s390x/unittests.cfg
+++ b/s390x/unittests.cfg
@@ -17,3 +17,8 @@ 
 #			 # to check separated by a space but each check
 #			 # parameter needs to be of the form <path>=<value>
 ##############################################################################
+
+[selftest-setup]
+file = selftest.elf
+groups = selftest
+extra_params = -append 'test 123'