aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test
AgeCommit message (Collapse)Author
2013-05-31When testing, don't tolerate warnings from the BEAM compilerBjörn Gustavsson
2013-05-31asn1_test_lib: Purge old code when loading a new moduleBjörn Gustavsson
In the 64-bit run-time, there is about 40Mb in old code after running the asn1 test suite. Since it is very easy to reclaim that memory, let's do it. Also get rid of the unnecessary call to code:soft_purge/1 just before loading the new code.
2013-05-31Clean up testPrimStringsBjörn Gustavsson
Eliminate use of line macros and asn1_wrapper.
2013-05-31ber_other/1: Test more specifications with the BER backendBjörn Gustavsson
2013-05-31testExtensionAddtionGroup/1: Clean up and enhanceBjörn Gustavsson
For the example from X.691, make sure to test that our encoded value is the same as given in X.691. Run the test for BER, too.
2013-05-31asn1_test_lib: Give more information when things goes wrongBjörn Gustavsson
Ensure that compilation errors of Erlang code gets printed. If compilation of an ASN.1 specification goes wrong, print out the filename of the offending specification. It can be seen in the test case log, but because most test cases run in a parallel group, the test case log is not available until all test case in the group have finished.
2013-05-31Normalize SIZE constraints to simplify backendsBjörn Gustavsson
2013-05-31PER: Fix aligments bugs for short stringsBjörn Gustavsson
The encoder wrongly assumed that a known multiplier string (such as IA5String) encoded as exactly 16 bits did not need to be aligned to an octet boundary. X.691 (07/2002) 27.5.7 says that it does. Since an OCTET STRING encoded to 16 bits (two octets) should not be aligned to an octet boundary, that means that asnct_imm:dec_string() needs an additional parameter to determine whether a string of a given length needs to be aligned. Furthermore, there is another subtle rule difference: An OCTET STRING which does not have fixed length is always aligned (in PER), but a known multiplier string is aligned if its upper bound is greater than or equal to 16. In encoding, make sure that short known multiplier strings and OCTET STRINGs with extensible sizes are not aligned when they are below the appropriate limit.
2013-05-31Correct encoding (decoding) of lengths less than the root rangeBjörn Gustavsson
Given the type: S ::= IA5String (SIZE (5, ...)) attempting to encode (to PER/UPER) a string shorter than 5 characters would fail. Similarly, attempting to decode such string in the BER format would fail. In the case of BER, we can do no range checks if the size constraint is extensible.
2013-05-31PER/UPER: Correct encoding of a length outside the root rangeBjörn Gustavsson
Consider a type with a size constraint with an extension marker such as: S ::= OCTET STRING (SIZE (0..10, ...)) For a length outside the root range (e.g. 42), the PER/UPER encoder will encode the length field in the same way as it would the type INTEGER (0..MAX) (i.e., as semi-constrained whole number), while the decoder would decode the length in the same way as length field without any constraint. Clearly, either the encoder or the decoder is wrong. But which one? Dubuisson's [1] book (page 442) says that the length should be encoded as a semi-constrained whole number if the length is outside the root range. The X.691 standard document [2] also says (e.g. in 15.11) that length fields should be a semi-constrained number, but gives a reference to section gives a reference to section 10.9, "General rules for encoding a length determinant", and not to to 10.7, "Encoding of a semi-constrained whole number". Reading the standard that way should imply that a length outside the root range should be encoded in the same way as an unconstrained length, and that the decoder does the right thing. Further support for that interpretation: - Larmouth's book [3], page 303. - The ASN.1 playground. [4] References: [1] http://www.oss.com/asn1/resources/books-whitepapers-pubs/dubuisson-asn1-book.PDF [2] http://www.itu.int/ITU-T/studygroups/com17/languages/X.691-0207.pdf [3] http://www.oss.com/asn1/resources/books-whitepapers-pubs/larmouth-asn1-book.pdf [4] http://asn1-playground.oss.com
2013-05-31testConstraints: Add more tests of SIZE constraintsBjörn Gustavsson
2013-05-31Fix handling of open interval constraints with pre-defined integersBjörn Gustavsson
The compiler would crash when given code such as the following: Type ::= INTEGER (lower<..<upper) lower INTEGER ::= 0 lower INTEGER ::= 42
2013-05-31PER/UPER: Share all code except encoding of primitivesBjörn Gustavsson
The only code that is really different between the PER and UPER backends is encoding of primitive types.
2013-05-31UPER: Fix bug in encoding/decoding of default typesBjörn Gustavsson
The wrong backend was used.
2013-05-31testInfObj: Introduce roundtrip/3 to simplify the test suiteBjörn Gustavsson
2013-05-31asn1_constructed_per: Optimize decoding of CHOICEBjörn Gustavsson
Optimize the decoding of CHOICE. Most important is to inline decoding of the extension bit (if present) and decoding of the choice index to give the BEAM compiler more opportunities for optimization. We will also change the structure of the generated code. The current code uses a flattened case for both the root and extension alternatives: case Choice + NumRootChoices * Ext of %% Root alternatives. 0 - ...; : LastRootAlternative -> ...; %% Extension alternatives. LastRootAlternative+1 -> ...; : %% Unknown extension. _ -> ...; end We will instead generate nested cases: case Ext of 0 -> case Choice of %% Root alternatives. 0 - ...; : LastRootAlternative -> ... end; 1 -> %% Extension alternatives. <Decode the open type here> case Choice of 0 -> ...; : LastExtensionAlternative -> ...; %% Unknown extension. _ -> ...; end end Nested cases should be slightly faster. For decoding of the extensions, it also makes it possible to hoist the decoding of the open type up from each case to before the case switching on the extension index, thus reducing the size of the generated code. We will also do another change to the structure. Currently, the big flat clase is wrapped in code that repackages the return values: {Alt,{Value,RemainingEncodedData}} = case Choice + NumRootChoices * Ext of : end, {{Value,Alt},RemainingEncodedData}. We still need to do the repackaging, but we can push it down to the case arm for decoding each alternative. In many cases, that will give the BEAM compiler the opportunity to avoid building the temporary tuples.
2013-04-18Merge branch 'maint-r16' into maintBjörn Gustavsson
* maint-r16: Prepare release Prepare release Do not count offline run-queues as empty Prepare release Prevent loss of objects after the extension marker Don't lose the extension mark for object set parameters Conflicts: erts/vsn.mk
2013-04-16Merge branch 'bjorn/asn1/fix-lost-extension-mark/OTP-10995' into maint-r16Erlang/OTP
* bjorn/asn1/fix-lost-extension-mark/OTP-10995: Prevent loss of objects after the extension marker Don't lose the extension mark for object set parameters
2013-04-03Prevent loss of objects after the extension markerBjörn Gustavsson
In an object set with a single root object, objects after the extension marker would be lost.
2013-04-03Don't lose the extension mark for object set parametersBjörn Gustavsson
When an object set is an actual parameter, the extension marker for the object set could get lost.
2013-03-15Eliminate latin1 encoded charactersBjörn Gustavsson
Characters encoded in latin1 (with no encoding comment) will not work in R17 since the default encoding will be UTF-8. The asn1 test suite contains two instances of comments written in Swedish. The comment in the .asn1config file is hard to understand and possibly out-of-date. Since the comment is not essential, simply delete it. Translate the comment in the other file to English.
2013-03-12PER: Ensure that the complete encoding is at least one byteBjörn Gustavsson
If the encoding is empty (i.e. if a top-level type is single-valued and therefore not encoding), the result should be a single zero byte.
2013-03-08PER/UPER: Correct decoding of ENUMERATEDs with a single valueBjörn Gustavsson
An ENUMERATED with as single value is not encoded. The decoder incorrectly assumed that it was encoded in one bit.
2013-02-22Update copyright yearsBjörn-Egil Dahlberg
2013-02-18Remove unused test casesBjörn Gustavsson
2013-02-18Run more tests with all backendsBjörn Gustavsson
Some tests are are only run with BER backend. Unless there is a special reason that the PER and UPER backends will not work, we should run all tests with all backends to get the best possible code coverage.
2013-02-18asn1_SUITE: Remove unused codeBjörn Gustavsson
2013-02-15BER: Fix broken table constraints inside a SET OF/SEQUENCE OFBjörn Gustavsson
2013-02-14Smoke test the 'der' optionBjörn Gustavsson
2013-02-14per,uper: Fix breakage of compilation of InformationFrameworkBjörn Gustavsson
Commit f16f43446a04c459486356c0b4ad517cc9201895 broke compilation of InformationFramework for per and uper.
2013-02-14Add NullTestBjörn Gustavsson
Was broken in some backends in R15. Make sure that we will notice if it breaks again.
2013-02-14asn1_SUITE: Shorten the path to case-specific directoryBjörn Gustavsson
On Windows, there is a limit to the number of characters in a filename. Therefore, we don't want unnecessarily use any longer path than necessary for case-specific directory. Since all test cases that put anything into priv_dir is asn1_SUITE, it is not necessary to include "asn1_SUITE" as part of the case-specific directory.
2013-02-14asn1_SUITE: Don't add priv_dir to the code pathBjörn Gustavsson
All generated and compiled code are now put into separate sub directories below priv_dir, so there is no point in adding priv_dir to the code path.
2013-02-14asn1 tests: Remove obsolete duplicates of ASN.1 specsBjörn Gustavsson
2013-02-07Merge branch 'maint'Björn Gustavsson
* maint: Prepare release Don't run testX420/1 on old slow Sparc systems testX420: Pass Options to the ASN.1 compiler asn1_erl_nif: Correct broken length encoding asn1_SUITE: Mend broken test_modified_x420/1 Revert "Prepare release" Conflicts: lib/asn1/doc/src/notes.xml lib/asn1/test/asn1_SUITE.erl
2013-02-06Merge branch 'bjorn/asn1/open-type-error/OTP-10805' into maint-r15Erlang/OTP
* bjorn/asn1/open-type-error/OTP-10805: asn1_erl_nif: Correct broken length encoding asn1_SUITE: Mend broken test_modified_x420/1
2013-02-06Merge branch 'bjorn/asn1/extension-addition-groups/OTP-10811' into maint-r15Erlang/OTP
* bjorn/asn1/extension-addition-groups/OTP-10811: Fix a bug for multiple extension addition groups
2013-02-06Don't run testX420/1 on old slow Sparc systemsBjörn Gustavsson
One and a half hour is not enough for it to finish.
2013-02-06testX420: Pass Options to the ASN.1 compilerBjörn Gustavsson
When the caller passed the 'der' option, it was ignored.
2013-02-04asn1_SUITE: Mend broken test_modified_x420/1Björn Gustavsson
The test_modified_x420/1 test case had several problems that prevented it to detect the bugs it was supposed to find: 1) There was a 'catch' at the top-level so that it could never fail. 2) There was a call to the now non-existing ssl_base64 module. 3) It did not test all options for the BER backend. While at it, also clean way the remaining ?line macros and some out-commented code.
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2013-01-24Remove vestiges of support for the {TypeName,Value} notationBjörn Gustavsson
Support in BER was removed in 3d1279f3cebfdd2483c3afea9f225613fe45cd00.
2013-01-23testPrimStrings: Test some constraintsBjörn Gustavsson
2013-01-23By default, encode BIT STRING to bitstringsBjörn Gustavsson
Add the option 'legacy_bit_string' to decode to the old list format.
2013-01-22Fix EXTERNAL 1990/1994 conversion information lossBjörn Gustavsson
There are two different definitions of the EXTERNAL data type in ASN.1: the original from 1990 and an updated from 1994. Both defintions are encoded in the same way (in BER). There are still systems in use that use the old definition of EXTERNAL, so the asn1 application must still support both. It has been decided that the asn1 application should handle both the forms without any compiler options. Internally the asn1 application uses the 1990 definition. The encode functions will accept both definitions, but translate the 1994 format to the 1990 format if needed. When decoding, it will decode to the 1990 definition format first and then translate to the 1994 defintion format. One problem with this approach is that the conversion to the 1994 format may not be loss-less (where the 1990 defintion had a CHOICE between an OPEN TYPE, OCTET STRING, or BIT STRING, the 1994 definition only supports an OCTET STRING), and therefore it might not be possible to correctly re-encode the data in the 1990 format. It seems that the only reliable way to handle that problem is to not do the conversion to the 1994 format if the conversion is not loss-less. (There is an attempt when translating to the 1990 format to recover the CHOICE alternative based on the Erlang type of the data value, but that is neither reliable nor future-proof.) That is, when decoding an EXTERNAL value, the resulting tuple could either conform to the 1990 or 1994 definition, and applications must be prepared to handle that. The mail conversation where this issue was first reported can be found here: http://erlang.org/pipermail/erlang-questions/2011-April/057697.html Reported-by: Harald Welte <[email protected]>
2013-01-22Optimize encoding of ENUMERATED in per and uperBjörn Gustavsson
Always pre-encode the values for the enumeration. Clean up the code and let the per and uper back-ends share the code.
2013-01-22BER: Correct bug in 'undec_rest'Björn Gustavsson
enif_make_new_binary() cannot return NULL, so while at it, remove the check for return value of enif_make_new_binary() being NULL.
2013-01-22Correct error handling for the NIF functionsBjörn Gustavsson
Also make sure that the error handling is contained within the asn1rt_nif module and does not leak out to generated code.
2013-01-22Generate modules with selected run-time functions for compiler usageBjörn Gustavsson
2013-01-22Remove the 'inline' and '{inline,OutputFile}' optionsBjörn Gustavsson