From nobody Thu Dec 18 00:58:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678293590; cv=none; d=zohomail.com; s=zohoarc; b=H1zgUYamIi/786dMaRbonS6WYRyqbJ5o46cbGmudsSokfNISS0g+AQ5dQ3HrUvIz30/e0Wqy6oafBekvZquIXKQluwoVCzlSBx1B1LZ4uDDokwnkplY1/OTg/aj51X148RYyG4PxL8jC5Up/m4D3myVEtY4mlQaWBbxdBEpZw6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678293590; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6Z3ZcKEsGYRAW6ZxzUgfBnL4XxMuvtFrZO2SjmjM6N4=; b=dtwNqQ3XxfEzGj94hMRnOt6XI3FcWnnuQqNB2NnKuPV2GugvVsfQgCPlQfUmaMXaNumLl6p9DoJudDB2bybi8MutB1ixZkloc6+/cqb5oB2S9zi85GsMYdReWR244DtMTFFtQftB+9sAaBA0kgd53PNhErc+CG+OR1/N5jLOQQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1678293590373445.21447283291866; Wed, 8 Mar 2023 08:39:50 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-504-PyCEWoHEOgSq0GOaQSnvKg-1; Wed, 08 Mar 2023 11:39:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 356103C10249; Wed, 8 Mar 2023 16:39:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 220322166B26; Wed, 8 Mar 2023 16:39:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1D365194864E; Wed, 8 Mar 2023 16:39:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 48AAC1946A6E for ; Wed, 8 Mar 2023 16:39:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2E0921121330; Wed, 8 Mar 2023 16:39:19 +0000 (UTC) Received: from virtlab420.virt.lab.eng.bos.redhat.com (virtlab420.virt.lab.eng.bos.redhat.com [10.19.152.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A89C1121314; Wed, 8 Mar 2023 16:39:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678293589; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6Z3ZcKEsGYRAW6ZxzUgfBnL4XxMuvtFrZO2SjmjM6N4=; b=I0DeZDN661uTI5O1hLBqCCT4Lj5Vq9NxvvvdRVQ3Q8AsXD6aXw71nJWKENVKF0l7ak+zj4 uY5Lw1nNOC9PKzp+biXf89pwFVWPjthrlnw7/9DlBq8byAEjWWzL/SVvhnI1D9mzsL7noR XR0ybYr7xoDfhewZMq7j7V21dn1ZI9c= X-MC-Unique: PyCEWoHEOgSq0GOaQSnvKg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [PATCH 09/16] rpcgen: add test case for XDR serialization Date: Wed, 8 Mar 2023 11:39:06 -0500 Message-Id: <20230308163913.338952-10-berrange@redhat.com> In-Reply-To: <20230308163913.338952-1-berrange@redhat.com> References: <20230308163913.338952-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678293591134100002 Test the serialization done by libtirpc, so that when we later switch to our own code, we can prove wire compatibility. Signed-off-by: Daniel P. Berrang=C3=A9 --- build-aux/syntax-check.mk | 11 +- scripts/rpcgen/tests/demo.x | 1 - scripts/rpcgen/tests/meson.build | 15 + scripts/rpcgen/tests/test_demo.c | 789 ++++++++++++++++++ scripts/rpcgen/tests/test_demo_enum.bin | Bin 0 -> 4 bytes .../tests/test_demo_enum_fixed_array.bin | Bin 0 -> 52 bytes .../tests/test_demo_enum_pointer_null.bin | Bin 0 -> 4 bytes .../tests/test_demo_enum_pointer_set.bin | Bin 0 -> 8 bytes .../rpcgen/tests/test_demo_enum_scalar.bin | Bin 0 -> 4 bytes .../test_demo_enum_variable_array_empty.bin | Bin 0 -> 4 bytes .../test_demo_enum_variable_array_set.bin | Bin 0 -> 16 bytes .../tests/test_demo_int_fixed_array.bin | Bin 0 -> 12 bytes .../tests/test_demo_int_pointer_null.bin | Bin 0 -> 4 bytes .../tests/test_demo_int_pointer_set.bin | Bin 0 -> 8 bytes scripts/rpcgen/tests/test_demo_int_scalar.bin | Bin 0 -> 4 bytes .../test_demo_int_variable_array_empty.bin | Bin 0 -> 4 bytes .../test_demo_int_variable_array_set.bin | Bin 0 -> 16 bytes .../tests/test_demo_opaque_fixed_array.bin | Bin 0 -> 12 bytes .../test_demo_opaque_variable_array_empty.bin | Bin 0 -> 4 bytes .../test_demo_opaque_variable_array_set.bin | Bin 0 -> 8 bytes .../test_demo_string_variable_array_empty.bin | Bin 0 -> 4 bytes .../test_demo_string_variable_array_set.bin | Bin 0 -> 12 bytes scripts/rpcgen/tests/test_demo_struct.bin | Bin 0 -> 8 bytes .../tests/test_demo_struct_fixed_array.bin | Bin 0 -> 136 bytes .../tests/test_demo_struct_pointer_null.bin | Bin 0 -> 4 bytes .../tests/test_demo_struct_pointer_set.bin | Bin 0 -> 12 bytes .../rpcgen/tests/test_demo_struct_scalar.bin | 1 + .../test_demo_struct_variable_array_empty.bin | Bin 0 -> 4 bytes .../test_demo_struct_variable_array_set.bin | Bin 0 -> 28 bytes .../tests/test_demo_test_struct_all_types.bin | Bin 0 -> 1752 bytes scripts/rpcgen/tests/test_demo_union_case.bin | Bin 0 -> 8 bytes .../rpcgen/tests/test_demo_union_default.bin | Bin 0 -> 8 bytes .../tests/test_demo_union_fixed_array.bin | Bin 0 -> 168 bytes .../tests/test_demo_union_no_default_case.bin | Bin 0 -> 8 bytes .../tests/test_demo_union_pointer_null.bin | Bin 0 -> 4 bytes .../tests/test_demo_union_pointer_set.bin | Bin 0 -> 12 bytes .../rpcgen/tests/test_demo_union_scalar.bin | Bin 0 -> 8 bytes .../test_demo_union_variable_array_empty.bin | Bin 0 -> 4 bytes .../test_demo_union_variable_array_set.bin | Bin 0 -> 28 bytes .../test_demo_union_void_default_case.bin | Bin 0 -> 8 bytes .../test_demo_union_void_default_default.bin | 1 + 41 files changed, 813 insertions(+), 5 deletions(-) create mode 100644 scripts/rpcgen/tests/test_demo.c create mode 100644 scripts/rpcgen/tests/test_demo_enum.bin create mode 100644 scripts/rpcgen/tests/test_demo_enum_fixed_array.bin create mode 100644 scripts/rpcgen/tests/test_demo_enum_pointer_null.bin create mode 100644 scripts/rpcgen/tests/test_demo_enum_pointer_set.bin create mode 100644 scripts/rpcgen/tests/test_demo_enum_scalar.bin create mode 100644 scripts/rpcgen/tests/test_demo_enum_variable_array_empt= y.bin create mode 100644 scripts/rpcgen/tests/test_demo_enum_variable_array_set.= bin create mode 100644 scripts/rpcgen/tests/test_demo_int_fixed_array.bin create mode 100644 scripts/rpcgen/tests/test_demo_int_pointer_null.bin create mode 100644 scripts/rpcgen/tests/test_demo_int_pointer_set.bin create mode 100644 scripts/rpcgen/tests/test_demo_int_scalar.bin create mode 100644 scripts/rpcgen/tests/test_demo_int_variable_array_empty= .bin create mode 100644 scripts/rpcgen/tests/test_demo_int_variable_array_set.b= in create mode 100644 scripts/rpcgen/tests/test_demo_opaque_fixed_array.bin create mode 100644 scripts/rpcgen/tests/test_demo_opaque_variable_array_em= pty.bin create mode 100644 scripts/rpcgen/tests/test_demo_opaque_variable_array_se= t.bin create mode 100644 scripts/rpcgen/tests/test_demo_string_variable_array_em= pty.bin create mode 100644 scripts/rpcgen/tests/test_demo_string_variable_array_se= t.bin create mode 100644 scripts/rpcgen/tests/test_demo_struct.bin create mode 100644 scripts/rpcgen/tests/test_demo_struct_fixed_array.bin create mode 100644 scripts/rpcgen/tests/test_demo_struct_pointer_null.bin create mode 100644 scripts/rpcgen/tests/test_demo_struct_pointer_set.bin create mode 100644 scripts/rpcgen/tests/test_demo_struct_scalar.bin create mode 100644 scripts/rpcgen/tests/test_demo_struct_variable_array_em= pty.bin create mode 100644 scripts/rpcgen/tests/test_demo_struct_variable_array_se= t.bin create mode 100644 scripts/rpcgen/tests/test_demo_test_struct_all_types.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_case.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_default.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_fixed_array.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_no_default_case.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_pointer_null.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_pointer_set.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_scalar.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_variable_array_emp= ty.bin create mode 100644 scripts/rpcgen/tests/test_demo_union_variable_array_set= .bin create mode 100644 scripts/rpcgen/tests/test_demo_union_void_default_case.= bin create mode 100644 scripts/rpcgen/tests/test_demo_union_void_default_defau= lt.bin diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 375fad188b..2599ba688f 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1358,7 +1358,7 @@ exclude_file_name_regexp--sc_avoid_strcase =3D ^tools= /(vsh\.h|nss/libvirt_nss_(lea exclude_file_name_regexp--sc_avoid_write =3D ^src/libvirt-stream\.c$$ =20 exclude_file_name_regexp--sc_gettext_init =3D \ - ^((tests|examples)/|tools/virt-login-shell.c) + ^((tests|examples)/|tools/virt-login-shell\.c$$|scripts/rpcgen/tests/test= _demo\.c$$) =20 exclude_file_name_regexp--sc_copyright_usage =3D \ ^COPYING(|\.LESSER)$$ @@ -1387,7 +1387,7 @@ exclude_file_name_regexp--sc_prohibit_close =3D \ (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/vir(file|event)\.c|src/libvirt= -stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/= nss/libvirt_nss_(leases|macs)\.c)|tools/virt-qemu-qmp-proxy$$) =20 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF =3D \ - (^tests/(nodedevmdevctl|virhostcpu|virpcitest|virstoragetest)data/|docs/= js/.*\.js|docs/fonts/.*\.woff|\.diff|tests/virconfdata/no-newline\.conf$$) + (^tests/(nodedevmdevctl|virhostcpu|virpcitest|virstoragetest)data/|docs/= js/.*\.js|docs/fonts/.*\.woff|\.diff|tests/virconfdata/no-newline\.conf$$|\= .bin) =20 exclude_file_name_regexp--sc_prohibit_fork_wrappers =3D \ (^(src/(util/(vircommand|virdaemon)|lxc/lxc_controller)|tests/testutils)= \.c$$) @@ -1429,10 +1429,10 @@ exclude_file_name_regexp--sc_prohibit_xmlURI =3D ^s= rc/util/viruri\.c$$ exclude_file_name_regexp--sc_prohibit_return_as_function =3D \.py$$ =20 exclude_file_name_regexp--sc_require_config_h =3D \ - ^(examples/c/.*/.*\.c|tools/virsh-edit\.c|tests/virmockstathelpers\.c|scr= ipts/rpcgen/tests/demo\.c)$$ + ^(examples/c/.*/.*\.c|tools/virsh-edit\.c|tests/virmockstathelpers\.c|scr= ipts/rpcgen/tests/(test_)?demo\.c)$$ =20 exclude_file_name_regexp--sc_require_config_h_first =3D \ - ^(examples/|tools/virsh-edit\.c$$|tests/virmockstathelpers.c) + ^(examples/|tools/virsh-edit\.c$$|tests/virmockstathelpers\.c$$|scripts/r= pcgen/tests/test_demo\.c$$) =20 exclude_file_name_regexp--sc_trailing_blank =3D \ /sysinfodata/.*\.data|/virhostcpudata/.*\.cpuinfo$$ @@ -1499,6 +1499,9 @@ exclude_file_name_regexp--sc_header-ifdef =3D \ exclude_file_name_regexp--sc_black =3D \ ^tools/|src/|tests/|ci/|run\.in|scripts/[^/]*\.py =20 +exclude_file_name_regexp--sc_spacing-check =3D \ + ^scripts/rpcgen/tests/test_demo\.[ch]$$ + ## -------------- ## ## Implementation ## ## -------------- ## diff --git a/scripts/rpcgen/tests/demo.x b/scripts/rpcgen/tests/demo.x index ec69913f3d..7260ad08df 100644 --- a/scripts/rpcgen/tests/demo.x +++ b/scripts/rpcgen/tests/demo.x @@ -74,7 +74,6 @@ struct TestStructAllTypes { bool sb; float sf; double sd; -/* quadruple sq; */ =20 int *ip; int ifa[TestConstDec]; diff --git a/scripts/rpcgen/tests/meson.build b/scripts/rpcgen/tests/meson.= build index 953a3dbede..b504684394 100644 --- a/scripts/rpcgen/tests/meson.build +++ b/scripts/rpcgen/tests/meson.build @@ -3,3 +3,18 @@ rpcgen_tests =3D files([ 'test_lexer.py', 'test_parser.py', ]) + + +test_demo =3D executable( + 'test_demo', + [ 'test_demo.c' ], + dependencies: [ + xdr_dep, glib_dep + ], +) + +test( + 'test_demo', + test_demo, + workdir: meson.current_source_dir(), +) diff --git a/scripts/rpcgen/tests/test_demo.c b/scripts/rpcgen/tests/test_d= emo.c new file mode 100644 index 0000000000..54f48e5637 --- /dev/null +++ b/scripts/rpcgen/tests/test_demo.c @@ -0,0 +1,789 @@ +#include +#include +#include + +#include "demo.h" +#include "demo.c" + +static void test_xdr(xdrproc_t proc, void *vorig, void *vnew, const char *= testname, bool fail) +{ + XDR xdr; + /* 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 *expected =3D NULL; + size_t explen; + size_t actlen; + g_autoptr(GError) err =3D NULL; + bool_t ret; + + /* Step 1: serialize the vorig and compare to the data in test .bin f= iles */ + xdrmem_create(&xdr, buf, buflen, XDR_ENCODE); + + ret =3D !!proc(&xdr, vorig); + g_assert_cmpint(ret, =3D=3D, !fail); + + if (fail) + goto cleanup; + + actlen =3D xdr_getpos(&xdr); + + if (getenv("VIR_TEST_REGENERATE_OUTPUT")) { + g_file_set_contents(expfile, buf, actlen, NULL); + } + + g_file_get_contents(expfile, &expected, &explen, &err); + if (err !=3D NULL) { + g_printerr("%s\n", err->message); + abort(); + } + + g_assert_cmpint(explen, =3D=3D, actlen); + + g_assert_cmpint(memcmp(buf, expected, actlen), =3D=3D, 0); + + xdr_destroy(&xdr); + + /* Step 2: de-serialize the state to create a new object */ + xdrmem_create(&xdr, buf, buflen, XDR_DECODE); + + ret =3D !!proc(&xdr, vnew); + g_assert_cmpint(ret, =3D=3D, true); + + actlen =3D xdr_getpos(&xdr); + g_assert_cmpint(explen, =3D=3D, actlen); + + xdr_destroy(&xdr); + + /* Step 3: serialize the new object again to prove we + * round-tripped the original object */ + memset(buf, 0, buflen); + + xdrmem_create(&xdr, buf, buflen, XDR_ENCODE); + + ret =3D !!proc(&xdr, vnew); + g_assert_cmpint(ret, =3D=3D, true); + + actlen =3D xdr_getpos(&xdr); + + g_assert_cmpint(explen, =3D=3D, actlen); + + g_assert_cmpint(memcmp(buf, expected, actlen), =3D=3D, 0); + xdr_destroy(&xdr); + + /* Step 4: free mem from the new object only; the orig + * was on the stack so leave untouched */ + xdrmem_create(&xdr, buf, buflen, XDR_FREE); + + ret =3D !!proc(&xdr, vnew); + g_assert_cmpint(ret, =3D=3D, true); + + cleanup: + xdr_destroy(&xdr); +} + +static void test_enum(void) +{ + TestEnum vorig =3D TEST_ENUM_TWO; + TestEnum vnew =3D 0; + + test_xdr((xdrproc_t)xdr_TestEnum, &vorig, &vnew, "enum", false); +} + +static void test_struct(void) +{ + TestStruct vorig =3D { + .c1 =3D 'a', .c2 =3D 'b', + }; + TestStruct vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestStruct, &vorig, &vnew, "struct", false); +} + +static void test_union_case(void) +{ + TestUnion vorig =3D { + .type =3D 20, .TestUnion_u =3D { .i1 =3D 1729 }, + }; + TestUnion vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnion, &vorig, &vnew, "union_case", false); +} + +static void test_union_default(void) +{ + TestUnion vorig =3D { + .type =3D 87539319, .TestUnion_u =3D { .i3 =3D 1729 }, + }; + TestUnion vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnion, &vorig, &vnew, "union_default", fal= se); +} + +static void test_union_void_default_case(void) +{ + TestUnionVoidDefault vorig =3D { + .type =3D 21, .TestUnionVoidDefault_u =3D { .i1 =3D 1729 }, + }; + TestUnionVoidDefault vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionVoidDefault, &vorig, &vnew, "union_vo= id_default_case", false); +} + +static void test_union_void_default_default(void) +{ + TestUnionVoidDefault vorig =3D { + .type =3D 87539319 + }; + TestUnionVoidDefault vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionVoidDefault, &vorig, &vnew, "union_vo= id_default_default", false); +} + +static void test_union_no_default_case(void) +{ + TestUnionNoDefault vorig =3D { + .type =3D 22, .TestUnionNoDefault_u =3D { .i1 =3D 1729 }, + }; + TestUnionNoDefault vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionNoDefault, &vorig, &vnew, "union_no_d= efault_case", false); +} + +static void test_union_no_default_default(void) +{ + TestUnionNoDefault vorig =3D { + .type =3D 87539319, + }; + TestUnionNoDefault vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionNoDefault, &vorig, &vnew, "union_no_d= efault_default", true); +} + +static void test_int_scalar(void) +{ + TestIntScalar vorig =3D 1729; + TestIntScalar vnew =3D 0; + + test_xdr((xdrproc_t)xdr_TestIntScalar, &vorig, &vnew, "int_scalar", fa= lse); +} + +static void test_int_pointer_set(void) +{ + int vorigp =3D 1729; + TestIntPointer vorig =3D &vorigp; + TestIntPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestIntPointer, &vorig, &vnew, "int_pointer_se= t", false); +} + +static void test_int_pointer_null(void) +{ + TestIntPointer vorig =3D NULL; + TestIntPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestIntPointer, &vorig, &vnew, "int_pointer_nu= ll", false); +} + +static void test_int_fixed_array(void) +{ + TestIntFixedArray vorig =3D { 1729, 0, 87539319 }; + TestIntFixedArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestIntFixedArray, + vorig, vnew, "int_fixed_array", false); +} + +static void test_int_variable_array_set(void) +{ + TestIntVariableArray vorig =3D { + .TestIntVariableArray_len =3D 3, + .TestIntVariableArray_val =3D (int[]) { 1729, 0, 87539319 } + }; + TestIntVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestIntVariableArray, + &vorig, &vnew, "int_variable_array_set", false); +} + +static void test_int_variable_array_overflow(void) +{ + TestIntVariableArray vorig =3D { + .TestIntVariableArray_len =3D 6, + .TestIntVariableArray_val =3D (int[]) { 1729, 0, 87539319, 0, 1729= } + }; + TestIntVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestIntVariableArray, + &vorig, &vnew, "int_variable_array_overflow", true); +} + +static void test_int_variable_array_empty(void) +{ + TestIntVariableArray vorig =3D { + .TestIntVariableArray_len =3D 0, + .TestIntVariableArray_val =3D (int[]) {0}, + }; + TestIntVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestIntVariableArray, + &vorig, &vnew, "int_variable_array_empty", false); +} + +static void test_string_variable_array_set(void) +{ + TestStringVariableArray vorig =3D (TestStringVariableArray) "taxis"; + TestStringVariableArray vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestStringVariableArray, + &vorig, &vnew, "string_variable_array_set", false); +} + +static void test_string_variable_array_empty(void) +{ + TestStringVariableArray vorig =3D (TestStringVariableArray)""; + TestStringVariableArray vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestStringVariableArray, + &vorig, &vnew, "string_variable_array_empty", false); +} + +static void test_opaque_fixed_array(void) +{ + TestOpaqueFixedArray vorig =3D { 0xca, 0xfe, 0x12, 0x23, 0x34, 0x45, 0= x56, 0x67, 0x78 }; + TestOpaqueFixedArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestOpaqueFixedArray, vorig, vnew, "opaque_fix= ed_array", false); +} + +static void test_opaque_variable_array_set(void) +{ + TestOpaqueVariableArray vorig =3D { + .TestOpaqueVariableArray_len =3D 3, + .TestOpaqueVariableArray_val =3D (char[]) { 0xca, 0xfe, 0x12 }, + }; + TestOpaqueVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestOpaqueVariableArray, + &vorig, &vnew, "opaque_variable_array_set", false); +} + +static void test_opaque_variable_array_overflow(void) +{ + TestOpaqueVariableArray vorig =3D { + .TestOpaqueVariableArray_len =3D 12, + .TestOpaqueVariableArray_val =3D (char[]) { + 0xca, 0xfe, 0x12, 0xca, 0xfe, 0x12, + 0xca, 0xfe, 0x12, 0xca, 0xfe, 0x12, + }, + }; + TestOpaqueVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestOpaqueVariableArray, + &vorig, &vnew, "opaque_variable_array_overflow", true); +} + +static void test_opaque_variable_array_empty(void) +{ + TestOpaqueVariableArray vorig =3D { + .TestOpaqueVariableArray_len =3D 0, + .TestOpaqueVariableArray_val =3D (char[]) {0}, + }; + TestOpaqueVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestOpaqueVariableArray, + &vorig, &vnew, "opaque_variable_array_empty", false); +} + +static void test_enum_scalar(void) +{ + TestEnumScalar vorig =3D TEST_ENUM_TWO; + TestEnumScalar vnew =3D 0; + + test_xdr((xdrproc_t)xdr_TestEnumScalar, + &vorig, &vnew, "enum_scalar", false); +} + +static void test_enum_pointer_set(void) +{ + TestEnum vorigp =3D TEST_ENUM_TWO; + TestEnumPointer vorig =3D &vorigp; + TestEnumPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestEnumPointer, + &vorig, &vnew, "enum_pointer_set", false); +} + +static void test_enum_pointer_null(void) +{ + TestEnumPointer vorig =3D NULL; + TestEnumPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestEnumPointer, + &vorig, &vnew, "enum_pointer_null", false); +} + +static void test_enum_fixed_array(void) +{ + TestEnumFixedArray vorig =3D { + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE + }; + TestEnumFixedArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestEnumFixedArray, vorig, vnew, "enum_fixed_a= rray", false); +} + +static void test_enum_variable_array_set(void) +{ + TestEnumVariableArray vorig =3D { + .TestEnumVariableArray_len =3D 3, + .TestEnumVariableArray_val =3D (TestEnum[]) { + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, + }, + }; + TestEnumVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestEnumVariableArray, + &vorig, &vnew, "enum_variable_array_set", false); +} + +static void test_enum_variable_array_overflow(void) +{ + TestEnumVariableArray vorig =3D { + .TestEnumVariableArray_len =3D 16, + .TestEnumVariableArray_val =3D (TestEnum[]) { + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + } + }; + TestEnumVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestEnumVariableArray, + &vorig, &vnew, "enum_variable_array_overflow", true); +} + +static void test_enum_variable_array_empty(void) +{ + TestEnumVariableArray vorig =3D { + .TestEnumVariableArray_len =3D 0, + .TestEnumVariableArray_val =3D (TestEnum[]) {0}, + }; + TestEnumVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestEnumVariableArray, + &vorig, &vnew, "enum_variable_array_empty", false); +} + +#define TEST_STRUCT_INIT (TestStruct) { .c1 =3D 0xca, .c2 =3D 0xfe } +#define TEST_STRUCT_INIT_ALT (TestStruct) { .c1 =3D 0x09, .c2 =3D 0x07 } + +static void test_struct_scalar(void) +{ + TestStructScalar vorig =3D TEST_STRUCT_INIT; + TestStructScalar vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestStructScalar, + &vorig, &vnew, "struct_scalar", false); +} + +static void test_struct_pointer_set(void) +{ + TestStruct vorigp =3D TEST_STRUCT_INIT; + TestStructPointer vorig =3D &vorigp; + TestStructPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestStructPointer, + &vorig, &vnew, "struct_pointer_set", false); +} + +static void test_struct_pointer_null(void) +{ + TestStructPointer vorig =3D NULL; + TestStructPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestStructPointer, + &vorig, &vnew, "struct_pointer_null", false); +} + +static void test_struct_fixed_array(void) +{ + TestStructFixedArray vorig =3D { + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT_ALT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST= _STRUCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_= INIT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST= _STRUCT_INIT, + TEST_STRUCT_INIT_ALT + }; + TestStructFixedArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestStructFixedArray, vorig, vnew, "struct_fix= ed_array", false); +} + +static void test_struct_variable_array_set(void) +{ + TestStructVariableArray vorig =3D { + .TestStructVariableArray_len =3D 3, + .TestStructVariableArray_val =3D (TestStruct[]) { + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT_ALT, + }, + }; + TestStructVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestStructVariableArray, + &vorig, &vnew, "struct_variable_array_set", false); +} + +static void test_struct_variable_array_overflow(void) +{ + TestStructVariableArray vorig =3D { + .TestStructVariableArray_len =3D 20, + .TestStructVariableArray_val =3D (TestStruct[]) { + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + } + }; + TestStructVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestStructVariableArray, + &vorig, &vnew, "struct_variable_array_overflow", true); +} + +static void test_struct_variable_array_empty(void) +{ + TestStructVariableArray vorig =3D { + .TestStructVariableArray_len =3D 0, + .TestStructVariableArray_val =3D (TestStruct[]) {}, + }; + TestStructVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestStructVariableArray, + &vorig, &vnew, "struct_variable_array_empty", false); +} + +#define TEST_UNION_INIT (TestUnion) { .type =3D 20, .TestUnion_u =3D { .i1= =3D 1729 } } +#define TEST_UNION_INIT_ALT (TestUnion) { .type =3D 1729, .TestUnion_u =3D= { .i3 =3D 87539319 } } + +static void test_union_scalar(void) +{ + TestUnionScalar vorig =3D TEST_UNION_INIT; + TestUnionScalar vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionScalar, + &vorig, &vnew, "union_scalar", false); +} + +static void test_union_pointer_set(void) +{ + TestUnion vorigp =3D TEST_UNION_INIT; + TestUnionPointer vorig =3D &vorigp; + TestUnionPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestUnionPointer, + &vorig, &vnew, "union_pointer_set", false); +} + +static void test_union_pointer_null(void) +{ + TestUnionPointer vorig =3D NULL; + TestUnionPointer vnew =3D NULL; + + test_xdr((xdrproc_t)xdr_TestUnionPointer, + &vorig, &vnew, "union_pointer_null", false); +} + +static void test_union_fixed_array(void) +{ + TestUnionFixedArray vorig =3D { + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UNION_= INIT_ALT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UN= ION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UN= ION_INIT, + TEST_UNION_INIT_ALT + }; + TestUnionFixedArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionFixedArray, vorig, vnew, "union_fixed= _array", false); +} + +static void test_union_variable_array_set(void) +{ + TestUnionVariableArray vorig =3D { + .TestUnionVariableArray_len =3D 3, + .TestUnionVariableArray_val =3D (TestUnion[]) { + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT_ALT, + }, + }; + TestUnionVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionVariableArray, + &vorig, &vnew, "union_variable_array_set", false); +} + +static void test_union_variable_array_overflow(void) +{ + TestUnionVariableArray vorig =3D { + .TestUnionVariableArray_len =3D 24, + .TestUnionVariableArray_val =3D (TestUnion[]) { + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + } + }; + TestUnionVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionVariableArray, + &vorig, &vnew, "union_variable_array_overflow", true); +} + +static void test_union_variable_array_empty(void) +{ + TestUnionVariableArray vorig =3D { + .TestUnionVariableArray_len =3D 0, + .TestUnionVariableArray_val =3D (TestUnion[]) {}, + }; + TestUnionVariableArray vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestUnionVariableArray, + &vorig, &vnew, "union_variable_array_empty", false); +} + +static void test_struct_all_types(void) +{ + int ip =3D 1729; + TestEnum ep =3D TEST_ENUM_TWO; + TestStruct sp =3D TEST_STRUCT_INIT; + TestUnion up =3D TEST_UNION_INIT; + TestStructAllTypes vorig =3D { + .sc =3D 'x', + .suc =3D 'y', + .ss =3D -7, + .sus =3D 14, + .si =3D -1729, + .sui =3D 1729, + .sh =3D -87539319, + .suh =3D -87539319, + .sb =3D true, + .sf =3D 0.1729, + .sd =3D 8753.9319, + .ip =3D &ip, + .ifa =3D { 1, 2, 3 }, + .iva =3D { + .iva_len =3D 3, + .iva_val =3D (int[]) { 7, 8, 9 }, + }, + .stva =3D (char *)"hello", + .ofa =3D { + 0x1, 0x2, 0x3, 0xff, 0xff, 0xff, 0xff, 0x1, + 0x1, 0x2, 0x3, 0xff, 0xff, 0xff, 0xff, 0x1, + 0x1, 0x2, 0x3, 0xff, 0xff, 0xff, 0xff, 0x1, + 0x1, 0x2, 0x3, 0xff, 0xff, 0xff, 0xff, 0x1, + 0xff, + }, + .ova =3D { + .ova_len =3D 3, + .ova_val =3D (char[]) { 0x1, 0xca, 0xfe }, + }, + .e1 =3D TEST_ENUM_ONE, + .e2 =3D TEST_ENUM_TWO, + .ep =3D &ep, + .efa =3D { + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, + }, + .eva =3D { + .eva_len =3D 3, + .eva_val =3D (TestEnum[]) { + TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + }, + }, + .s =3D TEST_STRUCT_INIT, + .sp =3D &sp, + .sfa =3D { + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST= _STRUCT_INIT_ALT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, = TEST_STRUCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, = TEST_STRUCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST= _STRUCT_INIT_ALT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, = TEST_STRUCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, = TEST_STRUCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST= _STRUCT_INIT_ALT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, = TEST_STRUCT_INIT, + TEST_STRUCT_INIT, + }, + .sva =3D { + .sva_len =3D 3, + .sva_val =3D (TestStruct[]) { + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, + }, + }, + .u =3D TEST_UNION_INIT, + .up =3D &up, + .ufa =3D { + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UN= ION_INIT_ALT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UNION_INIT_ALT, TES= T_UNION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TES= T_UNION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UN= ION_INIT_ALT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UNION_INIT_ALT, TES= T_UNION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TES= T_UNION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UN= ION_INIT_ALT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UNION_INIT_ALT, TES= T_UNION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT_ALT, + }, + .uva =3D { + .uva_len =3D 3, + .uva_val =3D (TestUnion[]) { + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT_ALT, + }, + }, + .tis =3D 1729, + .tip =3D &ip, + .tifa =3D { 1, 2, 3 }, + .tiva =3D { + .TestIntVariableArray_len =3D 3, + .TestIntVariableArray_val =3D (int[]) { 7, 8, 9 }, + }, + .tstva =3D (char *)"hello", + .tofa =3D { + 0x1, 0x2, 0x3, 0xff, 0xff, 0xff, 0xff, 0x1, + 0xff, + }, + .tova =3D { + .TestOpaqueVariableArray_len =3D 3, + .TestOpaqueVariableArray_val =3D (char[]) { 0x1, 0xca, 0xfe }, + }, + .tes =3D TEST_ENUM_ONE, + .tep =3D &ep, + .tefa =3D { + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + TEST_ENUM_ONE, + }, + .teva =3D { + .TestEnumVariableArray_len =3D 3, + .TestEnumVariableArray_val =3D (TestEnum[]) { + TEST_ENUM_TWO, TEST_ENUM_ONE, TEST_ENUM_TWO, + }, + }, + .tss =3D TEST_STRUCT_INIT, + .tsp =3D &sp, + .tsfa =3D { + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST= _STRUCT_INIT_ALT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, = TEST_STRUCT_INIT, + TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STRUCT_INIT, TEST_STR= UCT_INIT, + TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, = TEST_STRUCT_INIT, + TEST_STRUCT_INIT, + }, + .tsva =3D { + .TestStructVariableArray_len =3D 3, + .TestStructVariableArray_val =3D (TestStruct[]) { + TEST_STRUCT_INIT, TEST_STRUCT_INIT_ALT, TEST_STRUCT_INIT, + }, + }, + .tu =3D TEST_UNION_INIT, + .tup =3D &up, + .tufa =3D { + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UN= ION_INIT_ALT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UNION_INIT_ALT, TES= T_UNION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_INIT, TEST_UNION_= INIT, + TEST_UNION_INIT_ALT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TES= T_UNION_INIT, + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT, TEST_UN= ION_INIT_ALT, + TEST_UNION_INIT_ALT, + }, + .tuva =3D { + .TestUnionVariableArray_len =3D 3, + .TestUnionVariableArray_val =3D (TestUnion[]) { + TEST_UNION_INIT, TEST_UNION_INIT_ALT, TEST_UNION_INIT_ALT, + }, + }, + }; + TestStructAllTypes vnew =3D {0}; + + test_xdr((xdrproc_t)xdr_TestStructAllTypes, + &vorig, &vnew, "test_struct_all_types", false); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + g_test_set_nonfatal_assertions(); + + g_test_add_func("/xdr/enum", test_enum); + + g_test_add_func("/xdr/struct", test_struct); + + g_test_add_func("/xdr/union/case", test_union_case); + g_test_add_func("/xdr/union/default", test_union_default); + g_test_add_func("/xdr/union-void-default/case", test_union_void_defaul= t_case); + g_test_add_func("/xdr/union-void-default/default", test_union_void_def= ault_default); + g_test_add_func("/xdr/union-no-default/case", test_union_no_default_ca= se); + g_test_add_func("/xdr/union-no-default/default", test_union_no_default= _default); + + g_test_add_func("/xdr/int-scalar", test_int_scalar); + g_test_add_func("/xdr/int-pointer/set", test_int_pointer_set); + g_test_add_func("/xdr/int-pointer/null", test_int_pointer_null); + g_test_add_func("/xdr/int-fixed-array", test_int_fixed_array); + g_test_add_func("/xdr/int-variable-array/set", test_int_variable_array= _set); + g_test_add_func("/xdr/int-variable-array/overflow", test_int_variable_= array_overflow); + g_test_add_func("/xdr/int-variable-array/empty", test_int_variable_arr= ay_empty); + + g_test_add_func("/xdr/string-variable-array/set", test_string_variable= _array_set); + g_test_add_func("/xdr/string-variable-array/empty", test_string_variab= le_array_empty); + + g_test_add_func("/xdr/opaque-fixed-array", test_opaque_fixed_array); + g_test_add_func("/xdr/opaque-variable-array/set", test_opaque_variable= _array_set); + g_test_add_func("/xdr/opaque-variable-array/overflow", test_opaque_var= iable_array_overflow); + g_test_add_func("/xdr/opaque-variable-array/empty", test_opaque_variab= le_array_empty); + + g_test_add_func("/xdr/enum-scalar", test_enum_scalar); + g_test_add_func("/xdr/enum-pointer/set", test_enum_pointer_set); + g_test_add_func("/xdr/enum-pointer/null", test_enum_pointer_null); + g_test_add_func("/xdr/enum-fixed-array", test_enum_fixed_array); + g_test_add_func("/xdr/enum-variable-array/set", test_enum_variable_arr= ay_set); + g_test_add_func("/xdr/enum-variable-array/overflow", test_enum_variabl= e_array_overflow); + g_test_add_func("/xdr/enum-variable-array/empty", test_enum_variable_a= rray_empty); + + g_test_add_func("/xdr/struct-scalar", test_struct_scalar); + g_test_add_func("/xdr/struct-pointer/set", test_struct_pointer_set); + g_test_add_func("/xdr/struct-pointer/null", test_struct_pointer_null); + g_test_add_func("/xdr/struct-fixed-array", test_struct_fixed_array); + g_test_add_func("/xdr/struct-variable-array/set", test_struct_variable= _array_set); + g_test_add_func("/xdr/struct-variable-array/overflow", test_struct_var= iable_array_overflow); + g_test_add_func("/xdr/struct-variable-array/empty", test_struct_variab= le_array_empty); + + g_test_add_func("/xdr/union-scalar", test_union_scalar); + g_test_add_func("/xdr/union-pointer/set", test_union_pointer_set); + g_test_add_func("/xdr/union-pointer/null", test_union_pointer_null); + g_test_add_func("/xdr/union-fixed-array", test_union_fixed_array); + g_test_add_func("/xdr/union-variable-array/set", test_union_variable_a= rray_set); + g_test_add_func("/xdr/union-variable-array/overflow", test_union_varia= ble_array_overflow); + g_test_add_func("/xdr/union-variable-array/empty", test_union_variable= _array_empty); + + g_test_add_func("/xdr/struct-all-types", test_struct_all_types); + + return g_test_run(); +} diff --git a/scripts/rpcgen/tests/test_demo_enum.bin b/scripts/rpcgen/tests= /test_demo_enum.bin new file mode 100644 index 0000000000000000000000000000000000000000..b6a8ef3e7ca7c398cd8f65bb1e2= 1a23c0d251536 GIT binary patch literal 4 LcmZQzU|<3O00sa9 literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_enum_fixed_array.bin b/scripts/= rpcgen/tests/test_demo_enum_fixed_array.bin new file mode 100644 index 0000000000000000000000000000000000000000..869e8134ac62626562dda76a4ee= a95f9779ab266 GIT binary patch literal 52 WcmZQzU|?imU|<4bVrZZ;1_l5E1OO2L literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_enum_pointer_null.bin b/scripts= /rpcgen/tests/test_demo_enum_pointer_null.bin new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c63= 4f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_enum_pointer_set.bin b/scripts/= rpcgen/tests/test_demo_enum_pointer_set.bin new file mode 100644 index 0000000000000000000000000000000000000000..dc4fb37fcdbedaa327cd251b1a0= 666fe66a51917 GIT binary patch literal 8 PcmZQzU|?imU|<3O01p5J literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_enum_scalar.bin b/scripts/rpcge= n/tests/test_demo_enum_scalar.bin new file mode 100644 index 0000000000000000000000000000000000000000..b6a8ef3e7ca7c398cd8f65bb1e2= 1a23c0d251536 GIT binary patch literal 4 LcmZQzU|<3O00sa9 literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_enum_variable_array_empty.bin b= /scripts/rpcgen/tests/test_demo_enum_variable_array_empty.bin new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c63= 4f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_enum_variable_array_set.bin b/s= cripts/rpcgen/tests/test_demo_enum_variable_array_set.bin new file mode 100644 index 0000000000000000000000000000000000000000..63c142946282ff9fc3d398e1a7f= f0d354572875a GIT binary patch literal 16 TcmZQzU|?ooU|G=3DPly2k23-N( literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_string_variable_array_empty.bin= b/scripts/rpcgen/tests/test_demo_string_variable_array_empty.bin new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c63= 4f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_string_variable_array_set.bin b= /scripts/rpcgen/tests/test_demo_string_variable_array_set.bin new file mode 100644 index 0000000000000000000000000000000000000000..78e29054977ae0cf3a9a29e568c= 586407891c363 GIT binary patch literal 12 TcmZQzU|=3DmttjH{8U|;|M4JiUI literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_struct.bin b/scripts/rpcgen/tes= ts/test_demo_struct.bin new file mode 100644 index 0000000000000000000000000000000000000000..17d90c3c949f7e06f21a758ec28= 1b8739386ae32 GIT binary patch literal 8 PcmZQzU`S+OU`PT00#5+M literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_struct_fixed_array.bin b/script= s/rpcgen/tests/test_demo_struct_fixed_array.bin new file mode 100644 index 0000000000000000000000000000000000000000..f0e786ddea02cbd342ec9f6d3c6= ee2b090b38792 GIT binary patch literal 136 ncmezW|Np7~|NsAEU|`?`Vs;=3DKg^x=3Ddrj8H|(+{K3)x*RAqQp)G literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_struct_pointer_null.bin b/scrip= ts/rpcgen/tests/test_demo_struct_pointer_null.bin new file mode 100644 index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c63= 4f38c013fe9e4 GIT binary patch literal 4 LcmZQzU|;|M00aO5 literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_struct_pointer_set.bin b/script= s/rpcgen/tests/test_demo_struct_pointer_set.bin new file mode 100644 index 0000000000000000000000000000000000000000..572814793222ad03346747bb304= 1bb7eafc5205e GIT binary patch literal 12 ScmZQzU|{_J|Nki<{s#ae=3DLf_9 literal 0 HcmV?d00001 diff --git a/scripts/rpcgen/tests/test_demo_struct_scalar.bin b/scripts/rpc= gen/tests/test_demo_struct_scalar.bin new file mode 100644 index 0000000000..0e6959d56a --- /dev/null +++ b/scripts/rpcgen/tests/test_demo_struct_scalar.bin @@ -0,0 +1 @@ +