From 5210341783f4c3ca9611c7ea5e630fde4d067f10 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 2 Dec 2010 21:02:12 +0100 Subject: Really time to go home checkin. --- lib/snmp/test/modules.mk | 1 + lib/snmp/test/snmp_compiler_test.erl | 15 +++ lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib | 131 +++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 lib/snmp/test/snmp_test_data/AC-TEST-MIB.mib (limited to 'lib/snmp/test') diff --git a/lib/snmp/test/modules.mk b/lib/snmp/test/modules.mk index 6a0c3e9481..b90c6af482 100644 --- a/lib/snmp/test/modules.mk +++ b/lib/snmp/test/modules.mk @@ -62,6 +62,7 @@ COMPILER_MIB_FILES = \ OTP8574-MIB MIB_FILES = \ + AC-TEST-MIB.mib \ OLD-SNMPEA-MIB.mib \ OLD-SNMPEA-MIB-v2.mib \ Klas1.mib \ diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index ad77b01362..e2925ed6ed 100644 --- a/lib/snmp/test/snmp_compiler_test.erl +++ b/lib/snmp/test/snmp_compiler_test.erl @@ -44,6 +44,7 @@ oid_conflicts/1, imports/1, module_identity/1, + agent_capabilities/1, tickets/1, otp_6150/1, @@ -96,6 +97,7 @@ all(suite) -> oid_conflicts, imports, module_identity, + agent_capabilities, tickets ]. @@ -169,6 +171,19 @@ 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]), + + Dir = ?config(comp_dir, Config), + Mib = join(Dir,"AC-TEST-MIB.mib"), + ?line {ok, Mib} = snmpc:compile(Mib, [{outdir, Dir}, {verbosity,trace}]), + io:format("agent_capabilities -> Mib: ~n~p~n", [Mib]), + ok. + + otp_6150(suite) -> []; otp_6150(Config) when is_list(Config) -> 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 + "developer@small.company." + 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 +-- -- cgit v1.2.3 From 314e80f58bbee2924bf61bdc7b987750d58ca2ef Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Dec 2010 16:13:18 +0100 Subject: Typed more of the info. Also added more of it in the compiled mib. Also prepared for future module_compilance addition. --- lib/snmp/test/snmp_compiler_test.erl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/snmp/test') diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index e2925ed6ed..09fc417af4 100644 --- a/lib/snmp/test/snmp_compiler_test.erl +++ b/lib/snmp/test/snmp_compiler_test.erl @@ -79,10 +79,10 @@ 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]. fin_per_testcase(_Case, Config) when is_list(Config) -> - CompDir = ?config(comp_dir, Config), + CompDir = ?config(comp_dir, Config), ?line ok = ?DEL_DIR(CompDir), lists:keydelete(comp_dir, 1, Config). @@ -177,9 +177,17 @@ agent_capabilities(Config) when is_list(Config) -> put(tname,agent_capabilities), p("starting with Config: ~p~n", [Config]), - Dir = ?config(comp_dir, Config), - Mib = join(Dir,"AC-TEST-MIB.mib"), - ?line {ok, Mib} = snmpc:compile(Mib, [{outdir, Dir}, {verbosity,trace}]), + 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, Mib} = snmpc:compile(AcMib, [options, + version, + {i, [SnmpMibsDir, OtpMibsMibsDir]}, + {outdir, Dir}, + {verbosity, trace}]), io:format("agent_capabilities -> Mib: ~n~p~n", [Mib]), ok. -- cgit v1.2.3 From d7c6e2781c64e5e75add8a89d1b553bd5e9283f1 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 18 Feb 2011 19:18:12 +0100 Subject: Lost of fixes... *) Update release notes (with regard to module_compliance) *) New compiler options: agent_capabilities and module_compliance *) Update mib compiler option description (new options for agent_capabilities and module_compliance) *) New test case for module_compliance. *) Added test mib for module_complianc test case. *) Added some options for the MIB makefile. ... --- lib/snmp/test/modules.mk | 3 +- lib/snmp/test/snmp_compiler_test.erl | 77 ++++++++++-- lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib | 173 +++++++++++++++++++++++++++ 3 files changed, 245 insertions(+), 8 deletions(-) create mode 100644 lib/snmp/test/snmp_test_data/MC-TEST-MIB.mib (limited to 'lib/snmp/test') diff --git a/lib/snmp/test/modules.mk b/lib/snmp/test/modules.mk index b90c6af482..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 @@ -63,6 +63,7 @@ COMPILER_MIB_FILES = \ 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_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl index 09fc417af4..592b3efee2 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 @@ -45,6 +45,7 @@ imports/1, module_identity/1, agent_capabilities/1, + module_compliance/1, tickets/1, otp_6150/1, @@ -98,6 +99,7 @@ all(suite) -> imports, module_identity, agent_capabilities, + module_compliance, tickets ]. @@ -183,12 +185,73 @@ agent_capabilities(Config) when is_list(Config) -> OtpMibsMibsDir = join(OtpMibsPrivDir, "mibs"), Dir = ?config(mib_dir, Config), AcMib = join(Dir,"AC-TEST-MIB.mib"), - ?line {ok, Mib} = snmpc:compile(AcMib, [options, - version, - {i, [SnmpMibsDir, OtpMibsMibsDir]}, - {outdir, Dir}, - {verbosity, trace}]), - io:format("agent_capabilities -> Mib: ~n~p~n", [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. 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 + "developer@small.company." + 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 + + + -- cgit v1.2.3