From: Greg Hudson Date: Thu, 8 Mar 2012 00:37:44 +0000 (+0000) Subject: Simplify some ASN.1 array encoder tests X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=37bc418a7b3572ad5e31706719949aab6783b936;p=krb5.git Simplify some ASN.1 array encoder tests Use encode_run() for pa_data and etype_info tests. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25743 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/tests/asn.1/krb5_encode_test.c b/src/tests/asn.1/krb5_encode_test.c index 8f0fe3b99..e311aa870 100644 --- a/src/tests/asn.1/krb5_encode_test.c +++ b/src/tests/asn.1/krb5_encode_test.c @@ -506,35 +506,13 @@ main(argc, argv) krb5_pa_data **pa; ktest_make_sample_pa_data_array(&pa); - retval = encode_krb5_padata_sequence(pa,&(code)); - if (retval) { - com_err("encoding padata_sequence",retval,""); - exit(1); - } - encoder_print_results(code, "padata_sequence", ""); - retval = encode_krb5_typed_data(pa, &code); - if (retval) { - com_err("encoding typed_data", retval, ""); - exit(1); - } - encoder_print_results(code, "typed_data", ""); - + encode_run(*pa, "padata_sequence", "", encode_krb5_padata_sequence); + encode_run(*pa, "typed_data", "", encode_krb5_typed_data); ktest_destroy_pa_data_array(&pa); - } - - /****************************************************************/ - /* encode_padata_sequence (empty) */ - { - krb5_pa_data **pa; ktest_make_sample_empty_pa_data_array(&pa); - retval = encode_krb5_padata_sequence(pa,&(code)); - if (retval) { - com_err("encoding padata_sequence(empty)",retval,""); - exit(1); - } - encoder_print_results(code, "padata_sequence(empty)", ""); - + encode_run(*pa, "padata_sequence", "(empty)", + encode_krb5_padata_sequence); ktest_destroy_pa_data_array(&pa); } @@ -544,58 +522,32 @@ main(argc, argv) krb5_etype_info_entry **info; ktest_make_sample_etype_info(&info); - retval = encode_krb5_etype_info(info,&(code)); - if (retval) { - com_err("encoding etype_info",retval,""); - exit(1); - } - encoder_print_results(code, "etype_info", ""); + encode_run(*info, "etype_info", "", encode_krb5_etype_info); + ktest_destroy_etype_info_entry(info[2]); info[2] = 0; ktest_destroy_etype_info_entry(info[1]); info[1] = 0; - - retval = encode_krb5_etype_info(info,&(code)); - if (retval) { - com_err("encoding etype_info (only 1)",retval,""); - exit(1); - } - encoder_print_results(code, "etype_info (only 1)", ""); + encode_run(*info, "etype_info", "(only 1)", encode_krb5_etype_info); ktest_destroy_etype_info_entry(info[0]); info[0] = 0; - - retval = encode_krb5_etype_info(info,&(code)); - if (retval) { - com_err("encoding etype_info (no info)",retval,""); - exit(1); - } - encoder_print_results(code, "etype_info (no info)", ""); + encode_run(*info, "etype_info", "(no info)", encode_krb5_etype_info); ktest_destroy_etype_info(info); } - /* encode_etype_info 2*/ + /* encode_etype_info2 */ { krb5_etype_info_entry **info; ktest_make_sample_etype_info2(&info); - retval = encode_krb5_etype_info2(info,&(code)); - if (retval) { - com_err("encoding etype_info",retval,""); - exit(1); - } - encoder_print_results(code, "etype_info2", ""); + encode_run(*info, "etype_info2", "", encode_krb5_etype_info2); + ktest_destroy_etype_info_entry(info[2]); info[2] = 0; ktest_destroy_etype_info_entry(info[1]); info[1] = 0; + encode_run(*info, "etype_info2", "(only 1)", encode_krb5_etype_info2); - retval = encode_krb5_etype_info2(info,&(code)); - if (retval) { - com_err("encoding etype_info (only 1)",retval,""); - exit(1); - } - encoder_print_results(code, "etype_info2 (only 1)", ""); + /* etype_info2 sequences aren't allowed to be empty. */ ktest_destroy_etype_info(info); -/* ktest_destroy_etype_info_entry(info[0]); info[0] = 0;*/ - } /****************************************************************/ diff --git a/src/tests/asn.1/reference_encode.out b/src/tests/asn.1/reference_encode.out index be48cc113..1a9c3d667 100644 --- a/src/tests/asn.1/reference_encode.out +++ b/src/tests/asn.1/reference_encode.out @@ -39,10 +39,10 @@ encode_krb5_padata_sequence: 30 24 30 10 A1 03 02 01 0D A2 09 04 07 70 61 2D 64 encode_krb5_typed_data: 30 24 30 10 A0 03 02 01 0D A1 09 04 07 70 61 2D 64 61 74 61 30 10 A0 03 02 01 0D A1 09 04 07 70 61 2D 64 61 74 61 encode_krb5_padata_sequence(empty): 30 00 encode_krb5_etype_info: 30 33 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 30 05 A0 03 02 01 01 30 14 A0 03 02 01 02 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 32 -encode_krb5_etype_info (only 1): 30 16 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 -encode_krb5_etype_info (no info): 30 00 +encode_krb5_etype_info(only 1): 30 16 30 14 A0 03 02 01 00 A1 0D 04 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 +encode_krb5_etype_info(no info): 30 00 encode_krb5_etype_info2: 30 51 30 1E A0 03 02 01 00 A1 0D 1B 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 A2 08 04 06 73 32 6B 3A 20 30 30 0F A0 03 02 01 01 A2 08 04 06 73 32 6B 3A 20 31 30 1E A0 03 02 01 02 A1 0D 1B 0B 4D 6F 72 74 6F 6E 27 73 20 23 32 A2 08 04 06 73 32 6B 3A 20 32 -encode_krb5_etype_info2 (only 1): 30 20 30 1E A0 03 02 01 00 A1 0D 1B 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 A2 08 04 06 73 32 6B 3A 20 30 +encode_krb5_etype_info2(only 1): 30 20 30 1E A0 03 02 01 00 A1 0D 1B 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 A2 08 04 06 73 32 6B 3A 20 30 encode_krb5_pa_enc_ts: 30 1A A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A A1 05 02 03 01 E2 40 encode_krb5_pa_enc_ts (no usec): 30 13 A0 11 18 0F 31 39 39 34 30 36 31 30 30 36 30 33 31 37 5A encode_krb5_enc_data: 30 23 A0 03 02 01 00 A1 03 02 01 05 A2 17 04 15 6B 72 62 41 53 4E 2E 31 20 74 65 73 74 20 6D 65 73 73 61 67 65 diff --git a/src/tests/asn.1/trval_reference.out b/src/tests/asn.1/trval_reference.out index 7d95aef34..cc35e74ff 100644 --- a/src/tests/asn.1/trval_reference.out +++ b/src/tests/asn.1/trval_reference.out @@ -1094,14 +1094,14 @@ encode_krb5_etype_info: . . [0] [Integer] 2 . . [1] [Octet String] "Morton's #2" -encode_krb5_etype_info (only 1): +encode_krb5_etype_info(only 1): [Sequence/Sequence Of] . [Sequence/Sequence Of] . . [0] [Integer] 0 . . [1] [Octet String] "Morton's #0" -encode_krb5_etype_info (no info): +encode_krb5_etype_info(no info): [Sequence/Sequence Of] @@ -1120,7 +1120,7 @@ encode_krb5_etype_info2: . . [1] [General string] "Morton's #2" . . [2] [Octet String] "s2k: 2" -encode_krb5_etype_info2 (only 1): +encode_krb5_etype_info2(only 1): [Sequence/Sequence Of] . [Sequence/Sequence Of]