From nobody Sat May 11 22:22:22 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1701259374336465.6511333944561; Wed, 29 Nov 2023 04:02:54 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id B872C1AA9; Wed, 29 Nov 2023 07:02:53 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 05FA41AAC; Wed, 29 Nov 2023 07:00:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B3D301A56; Wed, 29 Nov 2023 07:00:15 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E13FC1A43 for ; Wed, 29 Nov 2023 07:00:14 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-zZFYg-0dNi-pc3IJLO19Ew-1; Wed, 29 Nov 2023 07:00:13 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E2B731C05156 for ; Wed, 29 Nov 2023 12:00:12 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E037C1596F for ; Wed, 29 Nov 2023 12:00:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: zZFYg-0dNi-pc3IJLO19Ew-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/2] rpcgen: tests: Allow running test_demo from anywhere Date: Wed, 29 Nov 2023 13:00:09 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: XLYATQAOOXXV6GSJALOY6RATQ3QLKDVB X-Message-ID-Hash: XLYATQAOOXXV6GSJALOY6RATQ3QLKDVB X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1701259374888000001 The test_demo program compares whether XDR encoded data match the expected output as read from a file. But the file path is not absolute and thus relative to CWD which means the program can run only from one specific directory. Do what we do in the rest of our test suite: define 'abs_srcdir' macro and prefix the path with it. Signed-off-by: Michal Privoznik Reviewed-by: Boris Fiuczynski Reviewed-by: Jiri Denemark --- scripts/rpcgen/tests/meson.build | 4 +++- scripts/rpcgen/tests/test_demo.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/rpcgen/tests/meson.build b/scripts/rpcgen/tests/meson.= build index 075b5a82cf..dfd757de7c 100644 --- a/scripts/rpcgen/tests/meson.build +++ b/scripts/rpcgen/tests/meson.build @@ -8,7 +8,9 @@ rpcgen_tests =3D files([ test_demo =3D executable( 'test_demo', [ 'test_demo.c' ], - c_args: cc_flags_relaxed_frame_limit, + c_args: [ + '-Dabs_srcdir=3D"@0@"'.format(meson.current_source_dir()), + ] + cc_flags_relaxed_frame_limit, dependencies: [ xdr_dep, glib_dep ], diff --git a/scripts/rpcgen/tests/test_demo.c b/scripts/rpcgen/tests/test_d= emo.c index d6be9e236d..1cdb9cfb82 100644 --- a/scripts/rpcgen/tests/test_demo.c +++ b/scripts/rpcgen/tests/test_demo.c @@ -12,7 +12,7 @@ static void test_xdr(xdrproc_t proc, void *vorig, void *v= new, const char *testna /* 128kb is big enough for any of our test data */ size_t buflen =3D 128 * 1000; g_autofree char *buf =3D g_new0(char, buflen); - g_autofree char *expfile =3D g_strdup_printf("test_demo_%s.bin", testn= ame); + g_autofree char *expfile =3D g_strdup_printf(abs_srcdir "/test_demo_%s= .bin", testname); g_autofree char *expected =3D NULL; size_t explen; size_t actlen; --=20 2.41.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 22:22:22 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1701259491653904.6500121445736; Wed, 29 Nov 2023 04:04:51 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BDEB31A6F; Wed, 29 Nov 2023 07:04:50 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DF8091A7E; Wed, 29 Nov 2023 07:00:31 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id BE2811A4D; Wed, 29 Nov 2023 07:00:16 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5B65E1A4A for ; Wed, 29 Nov 2023 07:00:15 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-xxM_UE8cNfCirpL6YNQENw-1; Wed, 29 Nov 2023 07:00:13 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 75BDD847723 for ; Wed, 29 Nov 2023 12:00:13 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 214F6C1596F for ; Wed, 29 Nov 2023 12:00:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: xxM_UE8cNfCirpL6YNQENw-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 2/2] rpcgen: tests: Run cleanly on platforms where char is unsigned Date: Wed, 29 Nov 2023 13:00:10 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: QUDUG5LDRH6HDVCZNRB3JLEI4YJPMGJA X-Message-ID-Hash: QUDUG5LDRH6HDVCZNRB3JLEI4YJPMGJA X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1701259493285000001 There are some platforms where 'char' is unsigned, by default (RPi, s390x to name a few). And because of how test_demo is written we are experiencing some test cases failing there. For instance: /xdr/struct-scalar is failing. This is because in the test (test_struct_scalar()), we have a struct with two chars. One is initialized to 0xca, the other 0xfe (note that both have the MSB set). The XDR encoder (xdr_TestStructScalar()) then calls xdr_char() on both of them. But XDR itself has no notion of char type, so under the hood, it expands it to int [1] and calls xdr_int(). And this is where the problem lies. On platforms where char is signed, the integer expansion results in 0xffffffca, but on platforms where char is unsigned it results in 0x000000ca. Two distinct results. The test then goes and compares the encoded buffer with an expected one (memcmp(), read from the disk earlier). This poses no problem for real life use, because when decoding those chars back, the padding is thrown away. To avoid tickling this issue, use values that don't have the MSB set. 1: https://git.linux-nfs.org/?p=3Dsteved/libtirpc.git;a=3Dblob;f=3Dsrc/xdr.= c;h=3D28d1382cc4853ecf1238d792af5016160435d1e0;hb=3DHEAD#l487 Reported-by: Boris Fiuczynski Signed-off-by: Michal Privoznik Reviewed-by: Boris Fiuczynski Reviewed-by: Jiri Denemark --- scripts/rpcgen/tests/test_demo.c | 2 +- .../tests/test_demo_struct_fixed_array.bin | Bin 136 -> 136 bytes .../tests/test_demo_struct_pointer_set.bin | Bin 12 -> 12 bytes .../rpcgen/tests/test_demo_struct_scalar.bin | Bin 8 -> 8 bytes .../test_demo_struct_variable_array_set.bin | Bin 28 -> 28 bytes .../tests/test_demo_test_struct_all_types.bin | Bin 1752 -> 1752 bytes 6 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rpcgen/tests/test_demo.c b/scripts/rpcgen/tests/test_d= emo.c index 1cdb9cfb82..a48ceccd58 100644 --- a/scripts/rpcgen/tests/test_demo.c +++ b/scripts/rpcgen/tests/test_demo.c @@ -373,7 +373,7 @@ static void test_enum_variable_array_empty(void) &vorig, &vnew, "enum_variable_array_empty", false); } =20 -#define TEST_STRUCT_INIT (TestStruct) { .c1 =3D 0xca, .c2 =3D 0xfe } +#define TEST_STRUCT_INIT (TestStruct) { .c1 =3D 0x4a, .c2 =3D 0x7e } #define TEST_STRUCT_INIT_ALT (TestStruct) { .c1 =3D 0x09, .c2 =3D 0x07 } =20 static void test_struct_scalar(void) diff --git a/scripts/rpcgen/tests/test_demo_struct_fixed_array.bin b/script= s/rpcgen/tests/test_demo_struct_fixed_array.bin index f0e786ddea02cbd342ec9f6d3c6ee2b090b38792..dfa991acbdb4b5cfd48a43d9c3e= 5e118282e2c95 100644 GIT binary patch literal 136 lcmZQzVDMsKV5kFPP9SCnVst((ahN(nG)zB?Mpq9O2LK;M1& literal 28 acmZQzU||0L|Nki<{>Q+;zzM|cFd6`$K?mjl diff --git a/scripts/rpcgen/tests/test_demo_test_struct_all_types.bin b/scr= ipts/rpcgen/tests/test_demo_test_struct_all_types.bin index 5ee4ee5a6d5e467e373add81d6266f4acee2a150..660c0e1b9c43046b790bda9c25a= 297653b714db0 100644 GIT binary patch literal 1752 zcmds%ziI+O5QpbH{0G6x!q>2}Q`1S_BVZw z2g^6Vncp1ixVIuQ7m>G=3D(q7q7j6@oh>U7vVuAtV6VgKP{T=3DhOD%iX(a^Zin4%2L;* z9(#9FS4&r0SAF_Co4sgI)Jof85izMppR(9~8FkM;d%b4bZ?$=3D{$0v;!M@4%Zu*U^wZugOQm4|6{1_@U3Eq0O4u_jJ$BH}R2;syo_3*NA-*um~f!N7@ z>+yGwWe2iD+3Y`6PBYN193M*OmxuYrSx&y)Z_ZyF^~34Yt?GlH#nH7$ zJ