* [v2] dma-buf: heaps: bugfix for selftest failure
@ 2020-03-07 14:02 Leon He
2020-03-13 17:15 ` shuah
2020-08-26 17:47 ` Ezequiel Garcia
0 siblings, 2 replies; 4+ messages in thread
From: Leon He @ 2020-03-07 14:02 UTC (permalink / raw)
To: shuah, sumit.semwal
Cc: Leon He, linux-kernel, dri-devel, linaro-mm-sig, linux-kselftest,
linux-media
From: Leon He <leon.he@unisoc.com>
There are two errors in the dmabuf-heap selftest:
1. The 'char name[5]' was not initialized to zero, which will cause
strcmp(name, "vgem") failed in check_vgem().
2. The return value of test_alloc_errors() should be reversed, other-
wise the while loop in main() will be broken.
Signed-off-by: Leon He <leon.he@unisoc.com>
---
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index cd5e1f6..836b185 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -22,7 +22,7 @@
static int check_vgem(int fd)
{
drm_version_t version = { 0 };
- char name[5];
+ char name[5] = { 0 };
int ret;
version.name_len = 4;
@@ -357,7 +357,7 @@ static int test_alloc_errors(char *heap_name)
if (heap_fd >= 0)
close(heap_fd);
- return ret;
+ return !ret;
}
int main(void)
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [v2] dma-buf: heaps: bugfix for selftest failure
2020-03-07 14:02 [v2] dma-buf: heaps: bugfix for selftest failure Leon He
@ 2020-03-13 17:15 ` shuah
2020-03-18 2:47 ` xiaolong he
2020-08-26 17:47 ` Ezequiel Garcia
1 sibling, 1 reply; 4+ messages in thread
From: shuah @ 2020-03-13 17:15 UTC (permalink / raw)
To: Leon He, sumit.semwal
Cc: Leon He, linux-kernel, dri-devel, linaro-mm-sig, linux-kselftest,
shuah, linux-media
On 3/7/20 7:02 AM, Leon He wrote:
> From: Leon He <leon.he@unisoc.com>
>
> There are two errors in the dmabuf-heap selftest:
> 1. The 'char name[5]' was not initialized to zero, which will cause
> strcmp(name, "vgem") failed in check_vgem().
> 2. The return value of test_alloc_errors() should be reversed, other-
> wise the while loop in main() will be broken.
>
> Signed-off-by: Leon He <leon.he@unisoc.com>
> ---
> tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> index cd5e1f6..836b185 100644
> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> @@ -22,7 +22,7 @@
> static int check_vgem(int fd)
> {
> drm_version_t version = { 0 };
> - char name[5];
> + char name[5] = { 0 };
> int ret;
>
> version.name_len = 4;
Please see my comment on v1 for this.
> @@ -357,7 +357,7 @@ static int test_alloc_errors(char *heap_name)
> if (heap_fd >= 0)
> close(heap_fd);
>
> - return ret;
> + return !ret;
This change doesn't make sense. Initializing ret to 0 is a better
way to go.
thanks,
-- Shuah
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [v2] dma-buf: heaps: bugfix for selftest failure
2020-03-13 17:15 ` shuah
@ 2020-03-18 2:47 ` xiaolong he
0 siblings, 0 replies; 4+ messages in thread
From: xiaolong he @ 2020-03-18 2:47 UTC (permalink / raw)
To: shuah
Cc: Leon He, linux-kernel, dri-devel, linaro-mm-sig, linux-kselftest,
linux-media
Dear Shuah:
> > @@ -357,7 +357,7 @@ static int test_alloc_errors(char *heap_name)
> > if (heap_fd >= 0)
> > close(heap_fd);
> >
> > - return ret;
> > + return !ret;
>
> This change doesn't make sense. Initializing ret to 0 is a better
> way to go.
>
I don't agree with you about this comment. Initializing ret to 0 can
not solve this problem.
Because the ret value will be override by the following
dmabuf_heap_alloc() calls.
static int test_alloc_errors(char *heap_name)
{
int ret;
ret = dmabuf_heap_alloc(...);
...
ret = dmabuf_heap_alloc(...);
...
ret = dmabuf_heap_alloc_fdflags(...);
...
return ret;
}
The purpose for test_alloc_errors() is to pass some invalid parameters
to dmabuf_heap_alloc()
and wish it return some errors. So -1 is what we expect from
test_alloc_errors(). But the code
in main() will break the loop when the ret value is -1. So I reversed
the return value in test_alloc_errors().
int main(void)
{
while(...) {
...
ret = test_alloc_errors(dir->d_name);
if (ret)
break;
}
}
thanks,
-- Leon
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [v2] dma-buf: heaps: bugfix for selftest failure
2020-03-07 14:02 [v2] dma-buf: heaps: bugfix for selftest failure Leon He
2020-03-13 17:15 ` shuah
@ 2020-08-26 17:47 ` Ezequiel Garcia
1 sibling, 0 replies; 4+ messages in thread
From: Ezequiel Garcia @ 2020-08-26 17:47 UTC (permalink / raw)
To: Leon He
Cc: Leon He, Linux Kernel Mailing List, dri-devel, linaro-mm-sig,
linux-kselftest, Shuah Khan, linux-media
Hi Leon, Shuah,
Thanks for the fix. I had this issue pending to fix,
but have been lazy about it, I appreciate you are taking care of it!
On Sat, 7 Mar 2020 at 11:03, Leon He <hexiaolong2008@gmail.com> wrote:
>
> From: Leon He <leon.he@unisoc.com>
>
> There are two errors in the dmabuf-heap selftest:
> 1. The 'char name[5]' was not initialized to zero, which will cause
> strcmp(name, "vgem") failed in check_vgem().
> 2. The return value of test_alloc_errors() should be reversed, other-
> wise the while loop in main() will be broken.
>
> Signed-off-by: Leon He <leon.he@unisoc.com>
> ---
> tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> index cd5e1f6..836b185 100644
> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> @@ -22,7 +22,7 @@
> static int check_vgem(int fd)
> {
> drm_version_t version = { 0 };
> - char name[5];
> + char name[5] = { 0 };
> int ret;
>
As Shuah already mentioned, I think we want to use strncmp
to be on the safe side.
> version.name_len = 4;
> @@ -357,7 +357,7 @@ static int test_alloc_errors(char *heap_name)
> if (heap_fd >= 0)
> close(heap_fd);
>
> - return ret;
> + return !ret;
I agree with Shuah, this change makes no sense, just drop it.
I think the fact this test was broken and nobody noticed
uncovers the fact that the test isn't being run.
Any reason why this test isn't a regular TARGET?
Or any idea how we can make sure this is run by CIs
and any other testing system?
Thanks!
Ezequiel
> }
>
> int main(void)
> --
> 2.7.4
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-26 17:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-07 14:02 [v2] dma-buf: heaps: bugfix for selftest failure Leon He
2020-03-13 17:15 ` shuah
2020-03-18 2:47 ` xiaolong he
2020-08-26 17:47 ` Ezequiel Garcia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).