diff mbox

[26/29] tests/tcg: use ARRAY_SIZE macro

Message ID 20170718061005.29518-27-f4bug@amsat.org
State New
Headers show

Commit Message

Philippe Mathieu-Daudé July 18, 2017, 6:10 a.m. UTC
Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/tcg/alpha/test-cond.c | 2 +-
 tests/tcg/alpha/test-ovf.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Marc-André Lureau July 18, 2017, 10:56 a.m. UTC | #1
Hi

On Mon, Jul 17, 2017 at 11:10 PM, Philippe Mathieu-Daudé
<f4bug@amsat.org> wrote:
> Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/tcg/alpha/test-cond.c | 2 +-
>  tests/tcg/alpha/test-ovf.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>

I think those do not include osdep.h

(sigh, tests/tcg would need some love ;)

> diff --git a/tests/tcg/alpha/test-cond.c b/tests/tcg/alpha/test-cond.c
> index 74adffaa69..e5596f10b8 100644
> --- a/tests/tcg/alpha/test-cond.c
> +++ b/tests/tcg/alpha/test-cond.c
> @@ -77,7 +77,7 @@ int main (void)
>  {
>    int i;
>
> -  for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
> +  for (i = 0; i < ARRAY_SIZE(vectors); i++)
>      if ((*vectors[i].func)(vectors[i].v) != vectors[i].r) {
>        write(1, "Failed\n", 7);
>        return 1;
> diff --git a/tests/tcg/alpha/test-ovf.c b/tests/tcg/alpha/test-ovf.c
> index 01c80e7525..43fc6ebb2e 100644
> --- a/tests/tcg/alpha/test-ovf.c
> +++ b/tests/tcg/alpha/test-ovf.c
> @@ -20,7 +20,7 @@ int main (void)
>  {
>    int i;
>
> -  for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
> +  for (i = 0; i < ARRAY_SIZE(vectors); i++)
>      if ((*vectors[i].func)(vectors[i].a, vectors[i].b) != vectors[i].r) {
>        write(1, "Failed\n", 7);
>      }
> --
> 2.13.2
>
>
Alex Bennée July 18, 2017, 11:16 a.m. UTC | #2
Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> Hi
>
> On Mon, Jul 17, 2017 at 11:10 PM, Philippe Mathieu-Daudé
> <f4bug@amsat.org> wrote:
>> Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  tests/tcg/alpha/test-cond.c | 2 +-
>>  tests/tcg/alpha/test-ovf.c  | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>
> I think those do not include osdep.h
>
> (sigh, tests/tcg would need some love ;)

Pranith has had a couple of revs at this:

  Subject: [PATCH v5 00/19] Cleanup of TCG tests
  Date: Thu,  1 Dec 2016 00:14:14 -0500
  Message-Id: <20161201051433.17168-1-bobby.prani@gmail.com>

We have the cross-compilers available as a fallback via docker although
not every one can seamlessly use it for building stuff. Is getting a
working cross-compiler setup too much of a hurdle fore those that want
to build cross-arch tests?

>
>> diff --git a/tests/tcg/alpha/test-cond.c b/tests/tcg/alpha/test-cond.c
>> index 74adffaa69..e5596f10b8 100644
>> --- a/tests/tcg/alpha/test-cond.c
>> +++ b/tests/tcg/alpha/test-cond.c
>> @@ -77,7 +77,7 @@ int main (void)
>>  {
>>    int i;
>>
>> -  for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
>> +  for (i = 0; i < ARRAY_SIZE(vectors); i++)
>>      if ((*vectors[i].func)(vectors[i].v) != vectors[i].r) {
>>        write(1, "Failed\n", 7);
>>        return 1;
>> diff --git a/tests/tcg/alpha/test-ovf.c b/tests/tcg/alpha/test-ovf.c
>> index 01c80e7525..43fc6ebb2e 100644
>> --- a/tests/tcg/alpha/test-ovf.c
>> +++ b/tests/tcg/alpha/test-ovf.c
>> @@ -20,7 +20,7 @@ int main (void)
>>  {
>>    int i;
>>
>> -  for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
>> +  for (i = 0; i < ARRAY_SIZE(vectors); i++)
>>      if ((*vectors[i].func)(vectors[i].a, vectors[i].b) != vectors[i].r) {
>>        write(1, "Failed\n", 7);
>>      }
>> --
>> 2.13.2
>>
>>


--
Alex Bennée
Marc-André Lureau July 18, 2017, 11:24 a.m. UTC | #3
Hi

On Tue, Jul 18, 2017 at 4:16 AM, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Marc-André Lureau <marcandre.lureau@gmail.com> writes:
>
>> Hi
>>
>> On Mon, Jul 17, 2017 at 11:10 PM, Philippe Mathieu-Daudé
>> <f4bug@amsat.org> wrote:
>>> Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> ---
>>>  tests/tcg/alpha/test-cond.c | 2 +-
>>>  tests/tcg/alpha/test-ovf.c  | 2 +-
>>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>
>> I think those do not include osdep.h
>>
>> (sigh, tests/tcg would need some love ;)
>
> Pranith has had a couple of revs at this:
>
>   Subject: [PATCH v5 00/19] Cleanup of TCG tests
>   Date: Thu,  1 Dec 2016 00:14:14 -0500
>   Message-Id: <20161201051433.17168-1-bobby.prani@gmail.com>
>
> We have the cross-compilers available as a fallback via docker although
> not every one can seamlessly use it for building stuff. Is getting a
> working cross-compiler setup too much of a hurdle fore those that want
> to build cross-arch tests?

Yes, I also did some experiments in cleaning up tests/tcg
(https://github.com/elmarco/qemu/tree/tcg-tests)

The trouble is I don't see an official/automated way to run tests/tcg
tests. Which cross-compiler should I use? When I played with this,
they all had various quirks, on Fedora, Debian or crosstool-ng. I
haven't looked at the docker tests, is this running tests/tcg test
somehow?
Philippe Mathieu-Daudé July 18, 2017, 1:41 p.m. UTC | #4
On Tue, Jul 18, 2017 at 8:16 AM, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Pranith has had a couple of revs at this:
>
>   Subject: [PATCH v5 00/19] Cleanup of TCG tests
>   Date: Thu,  1 Dec 2016 00:14:14 -0500
>   Message-Id: <20161201051433.17168-1-bobby.prani@gmail.com>
>
> We have the cross-compilers available as a fallback via docker although
> not every one can seamlessly use it for building stuff. Is getting a
> working cross-compiler setup too much of a hurdle fore those that want
> to build cross-arch tests?

I have a WiP branch using qemu to cross-run tests it _works_ funny but
when it fails it is not funny to understand what is really buggy...
/to be continued.../

Phil.
Alex Bennée July 18, 2017, 1:52 p.m. UTC | #5
Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> Hi
>
> On Tue, Jul 18, 2017 at 4:16 AM, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> Marc-André Lureau <marcandre.lureau@gmail.com> writes:
>>
>>> Hi
>>>
>>> On Mon, Jul 17, 2017 at 11:10 PM, Philippe Mathieu-Daudé
>>> <f4bug@amsat.org> wrote:
>>>> Applied using the Coccinelle semantic patch scripts/coccinelle/use_osdep.cocci
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>> ---
>>>>  tests/tcg/alpha/test-cond.c | 2 +-
>>>>  tests/tcg/alpha/test-ovf.c  | 2 +-
>>>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>
>>> I think those do not include osdep.h
>>>
>>> (sigh, tests/tcg would need some love ;)
>>
>> Pranith has had a couple of revs at this:
>>
>>   Subject: [PATCH v5 00/19] Cleanup of TCG tests
>>   Date: Thu,  1 Dec 2016 00:14:14 -0500
>>   Message-Id: <20161201051433.17168-1-bobby.prani@gmail.com>
>>
>> We have the cross-compilers available as a fallback via docker although
>> not every one can seamlessly use it for building stuff. Is getting a
>> working cross-compiler setup too much of a hurdle fore those that want
>> to build cross-arch tests?
>
> Yes, I also did some experiments in cleaning up tests/tcg
> (https://github.com/elmarco/qemu/tree/tcg-tests)
>
> The trouble is I don't see an official/automated way to run tests/tcg
> tests. Which cross-compiler should I use? When I played with this,
> they all had various quirks, on Fedora, Debian or crosstool-ng.

Debian at least have put a lot of work into getting cross-compilers
installed as part of the native distro with good multi-arch support. We
now use plain Debian 9 for most of the QEMU cross compiles - a few older
architectures still need Debian 8 with the emdebian overlay.

> I haven't looked at the docker tests, is this running tests/tcg test
> somehow?

No but as tests/tcg are all pretty simple and have less cross-compile
dependencies than QEMU itself it is fairly trivial to invoke docker to
do a cross-build for you in-place. e.g.:

  docker run --rm -t -u (id -u) -v (pwd):(pwd) -w (pwd) qemu:debian-armhf-cross arm-linux-gnueabihf-gcc tests/tcg/hello-arm.c

This is perhaps a bad example as there is a bit-rot that needs fixing.
The alternative is to mine the users PATH for fairly standard
cross-compile prefixes which work at least on Debian systems. I recently
submitted a patch to RISU that allowed you to use either in its
build-all-arches script:

  https://git.linaro.org/people/peter.maydell/risu.git/tree/build-all-archs

--
Alex Bennée
diff mbox

Patch

diff --git a/tests/tcg/alpha/test-cond.c b/tests/tcg/alpha/test-cond.c
index 74adffaa69..e5596f10b8 100644
--- a/tests/tcg/alpha/test-cond.c
+++ b/tests/tcg/alpha/test-cond.c
@@ -77,7 +77,7 @@  int main (void)
 {
   int i;
 
-  for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
+  for (i = 0; i < ARRAY_SIZE(vectors); i++)
     if ((*vectors[i].func)(vectors[i].v) != vectors[i].r) {
       write(1, "Failed\n", 7);
       return 1;
diff --git a/tests/tcg/alpha/test-ovf.c b/tests/tcg/alpha/test-ovf.c
index 01c80e7525..43fc6ebb2e 100644
--- a/tests/tcg/alpha/test-ovf.c
+++ b/tests/tcg/alpha/test-ovf.c
@@ -20,7 +20,7 @@  int main (void)
 {
   int i;
 
-  for (i = 0; i < sizeof (vectors)/sizeof(vectors[0]); i++)
+  for (i = 0; i < ARRAY_SIZE(vectors); i++)
     if ((*vectors[i].func)(vectors[i].a, vectors[i].b) != vectors[i].r) {
       write(1, "Failed\n", 7);
     }