From 67a171c8608d8bad19d4b9a22e5fa072f0d2d891 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 5 Feb 2013 14:57:13 +0100 Subject: [snmp/compiler] Add test case and test mib --- lib/snmp/test/snmp_compiler_test.erl | 28 +++++- lib/snmp/test/snmp_test_data/OTP10808-MIB.mib | 137 ++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 lib/snmp/test/snmp_test_data/OTP10808-MIB.mib diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index 4c5a945984..1840d37dfd 100644 --- a/lib/snmp/test/snmp_compiler_test.erl +++ b/lib/snmp/test/snmp_compiler_test.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2003-2012. All Rights Reserved. +%% Copyright Ericsson AB 2003-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -54,7 +54,8 @@ otp_6150/1, otp_8574/1, otp_8595/1, - otp_10799/1 + otp_10799/1, + otp_10808/1 ]). @@ -133,7 +134,7 @@ all() -> ]. groups() -> - [{tickets, [], [otp_6150, otp_8574, otp_8595, otp_10799]}]. + [{tickets, [], [otp_6150, otp_8574, otp_8595, otp_10799, otp_10808]}]. init_per_group(_GroupName, Config) -> Config. @@ -387,7 +388,7 @@ otp_8595(Config) when is_list(Config) -> snmpc:compile(MibFile, [{outdir, Dir}, {verbosity, trace}, {group_check, false}]), - io:format("otp_8595 -> Mib: ~n~p~n", [Mib]), + p("Mib: ~n~p~n", [Mib]), ok. @@ -408,6 +409,25 @@ otp_10799(Config) when is_list(Config) -> ok. +%%====================================================================== + +otp_10808(suite) -> + []; +otp_10808(Config) when is_list(Config) -> + put(tname, otp10808), + p("starting with Config: ~p~n", [Config]), + + Dir = ?config(case_top_dir, Config), + MibDir = ?config(mib_dir, Config), + MibFile = join(MibDir, "OTP10808-MIB.mib"), + ?line {ok, Mib} = + snmpc:compile(MibFile, [{outdir, Dir}, + {verbosity, trace}, + {group_check, false}]), + p("Mib: ~n~p~n", [Mib]), + ok. + + %%====================================================================== augments_extra_info(suite) -> diff --git a/lib/snmp/test/snmp_test_data/OTP10808-MIB.mib b/lib/snmp/test/snmp_test_data/OTP10808-MIB.mib new file mode 100644 index 0000000000..99c099e316 --- /dev/null +++ b/lib/snmp/test/snmp_test_data/OTP10808-MIB.mib @@ -0,0 +1,137 @@ +OTP10808-MIB DEFINITIONS ::= BEGIN + +IMPORTS + MODULE-IDENTITY, OBJECT-TYPE, enterprises, IpAddress FROM SNMPv2-SMI + RowStatus FROM SNMPv2-TC + ; + +otp10808MIB MODULE-IDENTITY + LAST-UPDATED "1004200000Z" + ORGANIZATION "Erlang/OTP" + CONTACT-INFO "www.erlang.org" + DESCRIPTION "The MIB module is used for testing a compiler feature" + ::= { otpSnmp 1 } + +ericsson OBJECT IDENTIFIER ::= { enterprises 193 } +otp OBJECT IDENTIFIER ::= { ericsson 19 } +otpApplications OBJECT IDENTIFIER ::= { otp 3 } +otpSnmp OBJECT IDENTIFIER ::= { otpApplications 3 } + +testMIBObjects OBJECT IDENTIFIER ::= { otp10808MIB 1 } + +testMIBObjectGroup OBJECT IDENTIFIER ::= { testMIBObjects 1 } + +-- Example Table 1 + +example-Table1 OBJECT-TYPE + SYNTAX SEQUENCE OF ExampleEntry1 + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "Example table 1" + ::= { testMIBObjectGroup 1 } + +example-Entry1 OBJECT-TYPE + SYNTAX ExampleEntry1 + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "Example table 1 entry" + INDEX { exampleIndex2, exampleIndex1 } + ::= { example-Table1 1 } + +ExampleEntry1 ::= SEQUENCE { + exampleIndex1 INTEGER, + exampleColumn1 OCTET STRING, + exampleNotAccessible1 OCTET STRING, + exampleRowStatus1 RowStatus +} + +exampleIndex1 OBJECT-TYPE + SYNTAX INTEGER (1..100) + MAX-ACCESS read-write + STATUS current + DESCRIPTION "The second index for this entry." + ::= { example-Entry1 1 } + +exampleColumn1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Example table column" + ::= { example-Entry1 2 } + +exampleNotAccessible1 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Example table column" + ::= { example-Entry1 3 } + +exampleRowStatus1 OBJECT-TYPE + SYNTAX RowStatus + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Example table RowStatus" + ::= { example-Entry1 4 } + + +-- Example Table 2 + +example-Table2 OBJECT-TYPE + SYNTAX SEQUENCE OF ExampleEntry2 + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "Example table 2" + ::= { testMIBObjectGroup 2 } + +example-Entry2 OBJECT-TYPE + SYNTAX ExampleEntry2 + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION "Example table entry" + INDEX { exampleIndex2 } + ::= { example-Table2 1 } + +ExampleEntry2 ::= SEQUENCE { + exampleIndex2 INTEGER, + exampleColumn2 OCTET STRING, + exampleNotAccessible2 OCTET STRING, + exampleRowStatus2 RowStatus +} + +exampleIndex2 OBJECT-TYPE + SYNTAX INTEGER (1..100) + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The index for this entry of table 2 + (and first index of table 1)." + ::= { example-Entry2 1 } + +exampleColumn2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Example table column" + ::= { example-Entry2 2 } + +exampleNotAccessible2 OBJECT-TYPE + SYNTAX OCTET STRING + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Example table column" + ::= { example-Entry2 3 } + +exampleRowStatus2 OBJECT-TYPE + SYNTAX RowStatus + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Example table RowStatus" + ::= { example-Entry2 4 } + +END -- cgit v1.2.3