diff options
Diffstat (limited to 'lib/snmp/test')
-rw-r--r-- | lib/snmp/test/modules.mk | 4 | ||||
-rw-r--r-- | lib/snmp/test/snmp_SUITE.erl | 123 | ||||
-rw-r--r-- | lib/snmp/test/snmp_compiler_test.erl | 109 | ||||
-rw-r--r-- | lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib | 131 | ||||
-rw-r--r-- | lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib | 173 |
5 files changed, 448 insertions, 92 deletions
diff --git a/lib/snmp/test/modules.mk b/lib/snmp/test/modules.mk index 6a0c3e9481..eacc749b53 100644 --- a/lib/snmp/test/modules.mk +++ b/lib/snmp/test/modules.mk @@ -2,7 +2,7 @@ # %CopyrightBegin% # -# Copyright Ericsson AB 2004-2010. All Rights Reserved. +# Copyright Ericsson AB 2004-2011. 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 @@ -62,6 +62,8 @@ COMPILER_MIB_FILES = \ OTP8574-MIB MIB_FILES = \ + AC-TEST-MIB.mib \ + MC-TEST-MIB.mib \ OLD-SNMPEA-MIB.mib \ OLD-SNMPEA-MIB-v2.mib \ Klas1.mib \ diff --git a/lib/snmp/test/snmp_SUITE.erl b/lib/snmp/test/snmp_SUITE.erl index 3f6473893b..b6d72da2fa 100644 --- a/lib/snmp/test/snmp_SUITE.erl +++ b/lib/snmp/test/snmp_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% Copyright Ericsson AB 1997-2011. 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 @@ -19,26 +19,14 @@ -module(snmp_SUITE). --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, +-export([all/0, + suite/0, + groups/0, + init_per_suite/1, end_per_suite/1, + init_per_group/2, end_per_group/2, init_per_testcase/2, end_per_testcase/2 ]). --export([]). - --export([ - - - - - - - - - - - - -]). %% %% ----- @@ -54,39 +42,43 @@ end_per_testcase(_Case, Config) when is_list(Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Top test case -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks, [ts_install_cth]}]. all() -> -[{group, app}, {group, compiler}, {group, misc}, - {group, agent}, {group, manager}]. + [{group, app}, + {group, compiler}, + {group, misc}, + {group, agent}, + {group, manager}]. groups() -> - [{app, [], [{group, app_test}, {group, appup_test}]}, - {compiler, [], [{group, compiler_test}]}, - {misc, [], - [{group, conf_test}, {group, pdus_test}, - {group, log_test}, {group, note_store_test}]}, - {agent, [], - [{group, mibs_test}, {group, nfilter_test}, - {group, agent_test}]}, - {manager, [], - [{group, manager_config_test}, - {group, manager_user_test}, {group, manager_test}]}, - {app_test, [], [{snmp_app_test, all}]}, - {appup_test, [], [{snmp_appup_test, all}]}, - {compiler_test, [], [{snmp_compiler_test, all}]}, - {conf_test, [], [{snmp_conf_test, all}]}, - {pdus_test, [], [{snmp_pdus_test, all}]}, - {log_test, [], [{snmp_log_test, all}]}, - {note_store_test, [], [{snmp_note_store_test, all}]}, - {mibs_test, [], [{snmp_agent_mibs_test, all}]}, - {nfilter_test, [], [{snmp_agent_nfilter_test, all}]}, - {agent_test, [], [{snmp_agent_test, all}]}, - {manager_config_test, [], - [{snmp_manager_config_test, all}]}, - {manager_user_test, [], - [{snmp_manager_user_test, all}]}, - {manager_test, [], [{snmp_manager_test, all}]}]. + [{app, [], [{group, app_test}, + {group, appup_test}]}, + {compiler, [], [{group, compiler_test}]}, + {misc, [], [{group, conf_test}, + {group, pdus_test}, + {group, log_test}, + {group, note_store_test}]}, + {agent, [], [{group, mibs_test}, + {group, nfilter_test}, + {group, agent_test}]}, + {manager, [], [{group, manager_config_test}, + {group, manager_user_test}, + {group, manager_test}]}, + {app_test, [], [{snmp_app_test, all}]}, + {appup_test, [], [{snmp_appup_test, all}]}, + {compiler_test, [], [{snmp_compiler_test, all}]}, + {conf_test, [], [{snmp_conf_test, all}]}, + {pdus_test, [], [{snmp_pdus_test, all}]}, + {log_test, [], [{snmp_log_test, all}]}, + {note_store_test, [], [{snmp_note_store_test, all}]}, + {mibs_test, [], [{snmp_agent_mibs_test, all}]}, + {nfilter_test, [], [{snmp_agent_nfilter_test, all}]}, + {agent_test, [], [{snmp_agent_test, all}]}, + {manager_config_test, [], [{snmp_manager_config_test, all}]}, + {manager_user_test, [], [{snmp_manager_user_test, all}]}, + {manager_test, [], [{snmp_manager_test, all}]}]. init_per_suite(Config) -> Config. @@ -95,41 +87,8 @@ end_per_suite(_Config) -> ok. init_per_group(_GroupName, Config) -> - Config. + Config. end_per_group(_GroupName, Config) -> - Config. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Config. diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index 98ffaf8bae..2e6020ae7a 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-2010. All Rights Reserved. +%% Copyright Ericsson AB 2003-2011. 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 @@ -37,15 +37,17 @@ %% External exports %%---------------------------------------------------------------------- -export([ - all/0,groups/0,init_per_group/2,end_per_group/2, + all/0, + groups/0, init_per_group/2, end_per_group/2, init_per_testcase/2, end_per_testcase/2, description/1, oid_conflicts/1, imports/1, module_identity/1, + agent_capabilities/1, + module_compliance/1, - otp_6150/1, otp_8574/1, otp_8595/1 @@ -78,7 +80,7 @@ init_per_testcase(_Case, Config) when is_list(Config) -> MibDir = join(lists:reverse(["snmp_test_data"|RL])), CompDir = join(Dir, "comp_dir/"), ?line ok = file:make_dir(CompDir), - [{comp_dir, CompDir},{mib_dir, MibDir}|Config]. + [{comp_dir, CompDir}, {mib_dir, MibDir} | Config]. end_per_testcase(_Case, Config) when is_list(Config) -> CompDir = ?config(comp_dir, Config), @@ -91,17 +93,24 @@ end_per_testcase(_Case, Config) when is_list(Config) -> %%====================================================================== all() -> -[description, oid_conflicts, imports, module_identity, - {group, tickets}]. + [ + description, + oid_conflicts, + imports, + module_identity, + agent_capabilities, + module_compliance, + {group, tickets} + ]. groups() -> [{tickets, [], [otp_6150, otp_8574, otp_8595]}]. init_per_group(_GroupName, Config) -> - Config. + Config. end_per_group(_GroupName, Config) -> - Config. + Config. @@ -168,6 +177,88 @@ module_identity(Config) when is_list(Config) -> ?SKIP(not_yet_implemented). +agent_capabilities(suite) -> + []; +agent_capabilities(Config) when is_list(Config) -> + put(tname,agent_capabilities), + p("starting with Config: ~p~n", [Config]), + + SnmpPrivDir = code:priv_dir(snmp), + SnmpMibsDir = join(SnmpPrivDir, "mibs"), + OtpMibsPrivDir = code:priv_dir(otp_mibs), + OtpMibsMibsDir = join(OtpMibsPrivDir, "mibs"), + Dir = ?config(mib_dir, Config), + AcMib = join(Dir,"AC-TEST-MIB.mib"), + ?line {ok, MibFile1} = snmpc:compile(AcMib, [options, + version, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib1} = snmp_misc:read_mib(MibFile1), + ?line {ok, MibFile2} = snmpc:compile(AcMib, [options, + version, + agent_capabilities, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib2} = snmp_misc:read_mib(MibFile2), + MEDiff = Mib2#mib.mes -- Mib1#mib.mes, + %% This is a rather pathetic test, but it is somthing... + io:format("agent_capabilities -> " + "~n MEDiff: ~p" + "~n Mib1: ~p" + "~n Mib2: ~p" + "~n", [MEDiff, Mib1, Mib2]), + case length(MEDiff) of + 2 -> + ok; + _BadLen -> + exit({unexpected_mes, MEDiff}) + end, + ok. + + +module_compliance(suite) -> + []; +module_compliance(Config) when is_list(Config) -> + put(tname,module_compliance), + p("starting with Config: ~p~n", [Config]), + + SnmpPrivDir = code:priv_dir(snmp), + SnmpMibsDir = join(SnmpPrivDir, "mibs"), + OtpMibsPrivDir = code:priv_dir(otp_mibs), + OtpMibsMibsDir = join(OtpMibsPrivDir, "mibs"), + Dir = ?config(mib_dir, Config), + AcMib = join(Dir,"MC-TEST-MIB.mib"), + ?line {ok, MibFile1} = snmpc:compile(AcMib, [options, + version, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib1} = snmp_misc:read_mib(MibFile1), + ?line {ok, MibFile2} = snmpc:compile(AcMib, [options, + version, + module_compliance, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), + ?line {ok, Mib2} = snmp_misc:read_mib(MibFile2), + MEDiff = Mib2#mib.mes -- Mib1#mib.mes, + %% This is a rather pathetic test, but it is somthing... + io:format("agent_capabilities -> " + "~n MEDiff: ~p" + "~n Mib1: ~p" + "~n Mib2: ~p" + "~n", [MEDiff, Mib1, Mib2]), + case length(MEDiff) of + 1 -> + ok; + _BadLen -> + exit({unexpected_mes, MEDiff}) + end, + ok. + + otp_6150(suite) -> []; otp_6150(Config) when is_list(Config) -> @@ -256,7 +347,7 @@ LAST-UPDATED \"0005290000Z\" Ericsson Utvecklings AB Open System Box 1505 -SE-125 25 �LVSJ�\" +SE-125 25 ÄLVSJÖ\" DESCRIPTION \" Objects for management \" diff --git a/lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib b/lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib new file mode 100644 index 0000000000..58defbe1cf --- /dev/null +++ b/lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib @@ -0,0 +1,131 @@ +--
+-- AC-TEST-MIB.mib
+-- MIB generated by MG-SOFT Visual MIB Builder Version 5.0 Build 250
+-- Tuesday, November 30, 2010 at 23:03:18
+--
+
+ AC-TEST-MIB DEFINITIONS ::= BEGIN
+
+ IMPORTS
+ otpExpr
+ FROM OTP-REG
+ OBJECT-GROUP, AGENT-CAPABILITIES
+ FROM SNMPv2-CONF
+ Integer32, OBJECT-TYPE, MODULE-IDENTITY, OBJECT-IDENTITY
+ FROM SNMPv2-SMI;
+
+
+ acTestModule MODULE-IDENTITY
+ LAST-UPDATED "201011302230Z" -- November 30, 2010 at 22:30 GMT
+ ORGANIZATION
+ "Ac Test Co."
+ CONTACT-INFO
+ "[email protected]."
+ DESCRIPTION
+ "Ac Test module."
+ ::= { reg 1 }
+
+
+
+--
+-- Node definitions
+--
+
+ acTest OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "Test area."
+ ::= { otpExpr 4321 }
+
+
+ reg OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "Registrations."
+ ::= { acTest 1 }
+
+
+ mib OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "Objects."
+ ::= { acTest 2 }
+
+
+ someObject OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Description."
+ ::= { mib 1 }
+
+
+ oneMore OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Description."
+ ::= { mib 2 }
+
+
+ grp OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "Groups
+ ."
+ ::= { acTest 3 }
+
+
+ basicGrp OBJECT-GROUP
+ OBJECTS { someObject }
+ STATUS current
+ DESCRIPTION
+ "Basic set of objects."
+ ::= { grp 1 }
+
+
+ allObjects OBJECT-GROUP
+ OBJECTS { someObject, oneMore }
+ STATUS current
+ DESCRIPTION
+ "Complete set."
+ ::= { grp 2 }
+
+
+ cap OBJECT-IDENTITY
+ STATUS current
+ DESCRIPTION
+ "Capabilities."
+ ::= { acTest 5 }
+
+
+ basicAgent AGENT-CAPABILITIES
+ PRODUCT-RELEASE
+ "Product release v1."
+ STATUS current
+ DESCRIPTION
+ "Basic agent."
+ SUPPORTS AC-TEST-MIB
+ INCLUDES { basicGrp }
+ ::= { cap 1 }
+
+
+ fullAgent AGENT-CAPABILITIES
+ PRODUCT-RELEASE
+ "Product release v2."
+ STATUS current
+ DESCRIPTION
+ "Full featured agent."
+ SUPPORTS AC-TEST-MIB
+ INCLUDES { allObjects }
+ ::= { cap 2 }
+
+
+
+ END
+
+--
+-- AC-TEST-MIB.mib
+--
diff --git a/lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib b/lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib new file mode 100644 index 0000000000..cadaa6f891 --- /dev/null +++ b/lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib @@ -0,0 +1,173 @@ +MC-TEST-MIB DEFINITIONS ::= BEGIN + +IMPORTS + otpExpr + FROM OTP-REG + MODULE-IDENTITY, OBJECT-TYPE, + mib-2, NOTIFICATION-TYPE, OBJECT-IDENTITY + FROM SNMPv2-SMI + TDomain, TAddress, DisplayString, TEXTUAL-CONVENTION, + AutonomousType, RowPointer, TimeStamp, + RowStatus, StorageType + FROM SNMPv2-TC + MODULE-COMPLIANCE, OBJECT-GROUP, NOTIFICATION-GROUP + FROM SNMPv2-CONF; + +mcTestModule MODULE-IDENTITY + LAST-UPDATED "9605160000Z" + ORGANIZATION "MC Test Co." + CONTACT-INFO + "[email protected]." + DESCRIPTION + "MC Test module." + ::= { reg 1 } + +mcObjects OBJECT IDENTIFIER ::= { mcTestModule 1 } + +-- MIB contains one group + +mcMisc OBJECT IDENTIFIER ::= { mcObjects 1 } +mcGeneral OBJECT IDENTIFIER ::= { mcObjects 2 } + + +mcTest OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Test area." + ::= { otpExpr 4322 } + + +reg OBJECT-IDENTITY + STATUS current + DESCRIPTION + "Registrations." + ::= { mcTest 1 } + + +mcTable OBJECT-TYPE + SYNTAX SEQUENCE OF McEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains one row per physical entity. There is + always at least one row for an 'overall' physical entity." + ::= { mcMisc 1 } + +mcEntry OBJECT-TYPE + SYNTAX McEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Table entry..." + INDEX { mcIndex } + ::= { mcTable 1 } + +McEntry ::= SEQUENCE { + mcIndex INTEGER, + mcName DisplayString, + mcStorageType StorageType, + mcRowStatus RowStatus +} + +mcIndex OBJECT-TYPE + SYNTAX INTEGER + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The index for this entry." + ::= { mcEntry 1 } + +mcName OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Name of... " + ::= { mcEntry 2 } + + +mcStorageType OBJECT-TYPE + SYNTAX StorageType + MAX-ACCESS read-create + STATUS current + DESCRIPTION + "The storage type for this conceptual row." + DEFVAL { nonVolatile } + ::= { mcEntry 3 } + +mcRowStatus OBJECT-TYPE + SYNTAX RowStatus + MAX-ACCESS read-create + STATUS current + DESCRIPTION + "The status of this conceptual row..." + ::= { mcEntry 4 } + + +-- last change time stamp for the whole MIB +mcTimeStamp OBJECT-TYPE + SYNTAX TimeStamp + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The sysUpTime value when of the last time *anything* in the + MIB was changed. " + ::= { mcGeneral 1 } + +-- Entity MIB Trap Definitions +mcTraps OBJECT IDENTIFIER ::= { mcTestModule 2 } +mcTrapPrefix OBJECT IDENTIFIER ::= { mcTraps 0 } + +mcConfigChange NOTIFICATION-TYPE + STATUS current + DESCRIPTION + "An mcConfigChange trap is sent when the value of + entLastChangeTime changes..." + ::= { mcTrapPrefix 1 } + +-- conformance information +mcConformance OBJECT IDENTIFIER ::= { mcTestModule 3 } + +mcCompliances OBJECT IDENTIFIER ::= { mcConformance 1 } +mcGroups OBJECT IDENTIFIER ::= { mcConformance 2 } + +-- compliance statements + + +mcCompliance MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for SNMP entities which implement + the MC Test MIB." + MODULE -- this module + MANDATORY-GROUPS { mcGeneralGroup, + mcNotificationsGroup } + ::= { mcCompliances 1 } + +-- MIB groupings + +mcGeneralGroup OBJECT-GROUP + OBJECTS { + mcName, + mcStorageType, + mcRowStatus, + mcTimeStamp + } + STATUS current + DESCRIPTION + "The collection of objects which are used to represent + general information..." + ::= { mcGroups 1 } + +mcNotificationsGroup NOTIFICATION-GROUP + NOTIFICATIONS { mcConfigChange } + STATUS current + DESCRIPTION + "The collection of notifications..." + ::= { mcGroups 2 } + + +END + + + |