Re: [PATCH 1/2] selftests/dmabuf-heap: conform test to TAP format output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/27/24 6:52 AM, T.J. Mercier wrote:
> On Sun, Feb 25, 2024 at 11:59 PM Muhammad Usama Anjum
> <usama.anjum@xxxxxxxxxxxxx> wrote:
>>
>> Conform the layout, informational and status messages to TAP. No
>> functional change is intended other than the layout of output messages.
>>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
>> ---
>>  .../selftests/dmabuf-heaps/dmabuf-heap.c      | 194 +++++++-----------
>>  1 file changed, 77 insertions(+), 117 deletions(-)
>>
>> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
>> index 890a8236a8ba7..6e538e346cb8f 100644
>> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
>> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
>> @@ -15,6 +15,7 @@
>>  #include <linux/dma-buf.h>
>>  #include <linux/dma-heap.h>
>>  #include <drm/drm.h>
>> +#include "../kselftest.h"
>>
>>  #define DEVPATH "/dev/dma_heap"
>>
>> @@ -90,14 +91,13 @@ static int dmabuf_heap_open(char *name)
>>         char buf[256];
>>
>>         ret = snprintf(buf, 256, "%s/%s", DEVPATH, name);
>> -       if (ret < 0) {
>> -               printf("snprintf failed!\n");
>> -               return ret;
>> -       }
>> +       if (ret < 0)
>> +               ksft_exit_fail_msg("snprintf failed!\n");
>>
>>         fd = open(buf, O_RDWR);
>>         if (fd < 0)
>> -               printf("open %s failed!\n", buf);
>> +               ksft_exit_fail_msg("open %s failed: %s\n", buf, strerror(errno));
>> +
>>         return fd;
>>  }
>>
>> @@ -140,7 +140,7 @@ static int dmabuf_sync(int fd, int start_stop)
>>
>>  #define ONE_MEG (1024 * 1024)
>>
>> -static int test_alloc_and_import(char *heap_name)
>> +static void test_alloc_and_import(char *heap_name)
>>  {
>>         int heap_fd = -1, dmabuf_fd = -1, importer_fd = -1;
>>         uint32_t handle = 0;
>> @@ -148,16 +148,12 @@ static int test_alloc_and_import(char *heap_name)
>>         int ret;
>>
>>         heap_fd = dmabuf_heap_open(heap_name);
>> -       if (heap_fd < 0)
>> -               return -1;
>>
>> -       printf("  Testing allocation and importing:  ");
>> +       ksft_print_msg("Testing allocation and importing:\n");
>>         ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0, &dmabuf_fd);
>> -       if (ret) {
>> -               printf("FAIL (Allocation Failed!)\n");
>> -               ret = -1;
>> -               goto out;
>> -       }
>> +       if (ret)
>> +               ksft_exit_fail_msg("FAIL (Allocation Failed!)\n");
>> +
>>         /* mmap and write a simple pattern */
>>         p = mmap(NULL,
>>                  ONE_MEG,
>> @@ -166,7 +162,7 @@ static int test_alloc_and_import(char *heap_name)
>>                  dmabuf_fd,
>>                  0);
>>         if (p == MAP_FAILED) {
>> -               printf("FAIL (mmap() failed)\n");
>> +               ksft_print_msg("FAIL (mmap() failed)\n");
>>                 ret = -1;
>>                 goto out;
>>         }
> 
> I think you should just ksft_exit_fail_msg these too and get rid of
> out / not bother with manual cleanup if we're going to exit anyway.
Not sure how I missed this. I'll send a v2.





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux