Commit 819b74f6 authored by thomson's avatar thomson Committed by Francis Dupont

[#65,!18] Now all tests uses test-module

parent 6bc78af9
......@@ -12,6 +12,8 @@ CLEANFILES = *.gcno *.gcda
TESTS_ENVIRONMENT = \
$(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
EXTRA_DIST = test-module.yang
TESTS =
if HAVE_GTEST
TESTS += run_unittests
......
module test-module {
yang-version 1.1;
namespace "urn:ietf:params:xml:ns:yang:test-module";
prefix tm;
import ietf-inet-types {
prefix inet;
}
organization "Sysrepo and ISC";
description
"ISC imported an example module from Sysrepo tests and adapted it
to kea testing regime.";
contact
"kea-dev@lists.isc.org";
container container {
config true;
list list {
leaf leaf {
type string;
}
leaf key1 {
type string;
}
leaf key2 {
type string;
}
key "key1 key2";
}
}
typedef threshold-power-dBm {
type union {
type decimal64 {
fraction-digits 2;
}
type enumeration {
enum off {
description "No threshold configured";
}
}
}
description "Power in dBm";
}
container main {
leaf enum {
type enumeration {
enum "yes" {
value 1;
}
enum "no" {
value 2;
}
enum "maybe" {
value 3;
}
}
}
leaf options {
type bits {
bit strict;
bit recursive;
bit logging;
}
}
leaf raw {
type binary;
}
leaf dec64 {
type decimal64{
fraction-digits 2;
}
}
leaf i8 {
type int8;
}
leaf i16 {
type int16;
}
leaf i32 {
type int32;
}
leaf i64 {
type int64;
}
leaf ui8 {
type uint8;
}
leaf ui16 {
type uint16;
}
leaf ui32 {
type uint32;
}
leaf ui64 {
type uint64;
}
leaf empty {
type empty;
}
leaf boolean {
type boolean;
}
leaf string {
type string;
}
leaf id_ref {
type identityref{
base base_id;
}
}
leaf-list numbers {
type uint8;
}
leaf instance_id {
type instance-identifier;
}
anyxml xml-data;
anydata any-data;
}
identity base_id;
identity id_1 {
base base_id;
}
identity id_2 {
base base_id;
}
list list {
key "key";
leaf key {
type string;
}
leaf id_ref {
type identityref{
base base_id;
}
}
leaf instance_id {
type instance-identifier;
}
leaf union {
type union{
type uint8;
type enumeration {
enum "infinity";
}
}
}
container wireless{
presence "wireless is enabled";
leaf vendor_name{
type string;
}
}
}
container transfer {
choice how {
default interval;
case interval {
leaf interval {
type uint16;
default 30;
units minutes;
}
}
case daily {
leaf daily {
type empty;
}
leaf time-of-day {
type string;
units 24-hour-clock;
default 1am;
}
}
case manual {
leaf manual {
type empty;
}
}
}
}
container location {
presence true;
leaf name {
type string;
}
leaf longitude {
type string;
mandatory true;
}
leaf latitude {
type string;
mandatory true;
}
}
leaf hexnumber{
type string {
length "0..4";
pattern "[0-9a-fA-F]*";
}
}
container interface {
leaf ifType {
type enumeration {
enum ethernet;
enum atm;
}
}
leaf ifMTU {
type uint32;
}
must "ifType != 'ethernet' or " +
"(ifType = 'ethernet' and ifMTU = 1500)" {
error-message "An ethernet MTU must be 1500";
}
must "ifType != 'atm' or " +
"(ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)" {
error-message "An atm MTU must be 64 .. 17966";
}
}
list user {
description "This is a list of users in the system.";
ordered-by user;
config true;
key "name";
leaf name {
type string;
}
leaf type {
type string;
}
leaf full-name {
type string;
}
}
leaf-list ordered-numbers {
ordered-by user;
type uint8;
}
list with_def {
config true;
key "name";
leaf name {
type string;
}
leaf num {
type int8;
default 0;
}
}
rpc activate-software-image {
input {
leaf image-name {
type string;
must ". != /top-level-default";
}
leaf location {
type string;
default "/";
must ". != 'invalid location'";
}
}
output {
leaf status {
type string;
must ". != 'invalid status'";
}
leaf version {
type string;
}
leaf location {
type string;
default "/";
}
container init-log {
list log-msg {
key "msg time";
leaf msg {
type string;
}
leaf time {
type uint32;
}
leaf msg-type {
type enumeration {
enum "error" {
value 1;
}
enum "warning" {
value 2;
}
enum "debug" {
value 3;
}
}
}
}
}
}
}
leaf top-level-default {
type string;
default "default value";
}
container university {
container students {
list student {
ordered-by user;
config true;
key "name";
leaf name {
type string;
}
leaf age {
type uint8;
}
}
}
container classes {
list class {
config true;
key "title";
leaf title {
type string;
}
list student {
key "name";
leaf name {
type leafref {
path "../../../../students/student/name";
}
}
leaf age {
type leafref {
path "../../../../students/student[name = current()/../name]/age";
}
}
}
}
}
}
container leafref-chain {
leaf A {
type leafref {
path "../B";
}
}
leaf B {
type leafref {
path "../C";
}
}
leaf C {
type leafref {
path "../D";
}
}
leaf D {
type string;
}
}
grouping link {
container source {
leaf address {
type inet:ipv4-address;
}
leaf interface {
type string;
}
}
container destination {
leaf address {
type inet:ipv4-address;
}
leaf interface {
type string;
}
}
leaf MTU {
type uint16;
default 1500;
}
}
notification link-discovered {
uses link;
}
notification link-removed {
uses link;
}
container kernel-modules {
list kernel-module {
key "name";
leaf name {
type string;
}
leaf location {
type string;
default "/lib/modules";
}
leaf loaded {
type boolean;
}
action load {
input {
leaf params {
mandatory "true";
type string;
}
leaf force {
type boolean;
default "false";
when "../../loaded = 'false'";
}
leaf dry-run {
type boolean;
default false;
}
}
output {
leaf return-code {
type uint8;
}
}
}
action unload { }
action get-dependencies {
output {
leaf-list dependency {
type string;
}
leaf location {
type leafref {
path "/kernel-modules/kernel-module[name = current()/../../name]/location";
}
}
leaf location2 {
type leafref {
path "../../location";
}
}
}
}
}
}
typedef uniontpdf {
type union {
type string {
pattern "disabled";
}
type uint8 {
range "1..100";
}
}
default "disabled";
}
typedef enumtpdf {
type enumeration {
enum "a" {
value 1;
}
enum "b" {
value 2;
}
enum "c" {
value 3;
}
}
}
typedef multiplunions {
type union {
type uniontpdf;
type enumtpdf;
type union {
type boolean;
type decimal64 {
fraction-digits 2;
}
}
}
}
typedef leafreftpdf {
type leafref {
path "/list/key";
}
}
typedef inttpdf {
type uint8 {
range "1..100";
}
}
container tpdfs {
leaf unival {
type uniontpdf;
}
leaf leafrefval {
type leafreftpdf;
}
leaf intval {
type inttpdf;
}
leaf undecided {
type multiplunions;
}
}
leaf dec64-in-union {
type threshold-power-dBm;
}
container presence-container {
presence "presence-container";
leaf topleaf1 {
type int8;
}
leaf topleaf2 {
type int8;
}
container child1 {
leaf child1-leaf {
type int8;
}
container grandchild1 {
leaf grandchild1-leaf {
type int8;
default 10;
}
}
}
container child2 {
leaf child2-leaf {
type int8;
}
container grandchild2 {
leaf grandchild2-leaf1 {
type int8;
}
leaf grandchild2-leaf2 {
type int8;
}
leaf grandchild2-leaf3 {
type int8;
}
}
}
}
}
......@@ -18,13 +18,15 @@ using namespace isc::yang;
namespace {
const std::string TEST_MODULE="example-module";
const std::string TEST_MODULE="test-module";
// This test verifies if there are test models installed and accessible.
// To run those tests properly, the following models need to be installed:
// - example-module
// - test-module
TEST(TranslatorBasicTest, testEnvironmentCheck) {
/// @brief checks if specified schema is installed and available in sysrepo
///
/// @name name of the schema to be checked (without .yang)
/// @verbose print installed schemas?
/// @return true if installed, false otherwise.
bool schemaInstalled(const std::string& name, bool verbose = false) {
// Get a connection.
S_Connection conn(new Connection("translator unittests"));
// Get a session.
......@@ -33,24 +35,37 @@ TEST(TranslatorBasicTest, testEnvironmentCheck) {
S_Yang_Schemas schemas = sess->list_schemas();
size_t schema_cnt = schemas->schema_cnt();
std::cout << "There are " << schema_cnt << " YANG schema(s) installed:" << endl;
if (verbose) {
cout << "There are " << schema_cnt << " YANG schema(s) installed:" << endl;