[SSSD] [PATCH] sss_nss_idmap-tests: Use different prepared buffers for big endian

Sumit Bose sbose at redhat.com
Mon May 4 11:20:05 UTC 2015


On Mon, May 04, 2015 at 07:41:39AM +0200, Lukas Slebodnik wrote:
> ehlo,
> 
> It is a long lasting bug in unit tests.
> Timo reported it[1] 10 months ago.
> 
> Siple patch attached.
> 
> LS

Thank you, the patch looks good and is working as expected on big and
little endian platforms, so ACK.
CI: http://sssd-ci.duckdns.org/logs/job/13/81/summary.html

bye,
Sumit

> From a45477493586a86b011550b8913efd0175b2db75 Mon Sep 17 00:00:00 2001
> From: Lukas Slebodnik <lslebodn at redhat.com>
> Date: Mon, 4 May 2015 07:34:19 +0200
> Subject: [PATCH] sss_nss_idmap-tests: Use different prepared buffers for big
>  endian
> 
> We get error EBADMSG instead of EOK due to endianess issue
> 
> [==========] Running 2 test(s).
> [ RUN      ] test_getsidbyname
> 0x4a != 0
> src/tests/cmocka/sss_nss_idmap-tests.c:108: error: Failure!
> 
> [  FAILED  ] test_getsidbyname
> [ RUN      ] test_getorigbyname
> 0x4a != 0
> src/tests/cmocka/sss_nss_idmap-tests.c:127: error: Failure!
> 
> [  FAILED  ] test_getorigbyname
> ---
>  src/tests/cmocka/sss_nss_idmap-tests.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> ---
>  src/tests/cmocka/sss_nss_idmap-tests.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/tests/cmocka/sss_nss_idmap-tests.c b/src/tests/cmocka/sss_nss_idmap-tests.c
> index 4ba8f2f9265389d63983e44fe14f026c9a7b8d50..8807eca619d7b07d919168e5629042cf38f654ac 100644
> --- a/src/tests/cmocka/sss_nss_idmap-tests.c
> +++ b/src/tests/cmocka/sss_nss_idmap-tests.c
> @@ -28,6 +28,7 @@
>  
>  
>  #include "util/util.h"
> +#include "util/sss_endian.h"
>  
>  #include "sss_client/idmap/sss_nss_idmap.h"
>  #include "tests/cmocka/common_mock.h"
> @@ -42,12 +43,23 @@ struct sss_nss_make_request_test_data {
>      enum nss_status nss_status;
>  };
>  
> +#if (__BYTE_ORDER == __LITTLE_ENDIAN)
>  uint8_t buf1[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00};
>  uint8_t buf2[] = {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00};
>  uint8_t buf3[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00};
>  uint8_t buf4[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 'x'};
>  
>  uint8_t buf_orig1[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 'k', 'e', 'y', 0x00, 'v', 'a', 'l', 'u', 'e', 0x00};
> +#elif (__BYTE_ORDER == __BIG_ENDIAN)
> +uint8_t buf1[] = {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00};
> +uint8_t buf2[] = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00};
> +uint8_t buf3[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 0x00};
> +uint8_t buf4[] = {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 't', 'e', 's', 't', 'x'};
> +
> +uint8_t buf_orig1[] = {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'k', 'e', 'y', 0x00, 'v', 'a', 'l', 'u', 'e', 0x00};
> +#else
> + #error "unknow endianess"
> +#endif
>  
>  enum nss_status sss_nss_make_request(enum sss_cli_command cmd,
>                        struct sss_cli_req_data *rd,
> -- 
> 2.4.0
> 

> _______________________________________________
> sssd-devel mailing list
> sssd-devel at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/sssd-devel




More information about the sssd-devel mailing list