blob: 9fb5fd3170b0991a63a06a82e8d81616eb11db85 [file] [log] [blame]
Joey Armstrong44fa7d82022-11-01 17:46:04 -04001#!/usr/bin/env python
2'''This script is an aggregate for testing resources.'''
3
4# -----------------------------------------------------------------------
5# Copyright 2022 Open Networking Foundation (ONF) and the ONF Contributors
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18# -----------------------------------------------------------------------
19
20##-------------------##
21##---] GLOBALS [---##
22##-------------------##
23
24##-------------------##
25##---] IMPORTS [---##
26##-------------------##
27import sys
28import pprint
29
30from flog.main import utils as main_utils
31from flog.main import argparse as main_getopt
32
33# from flog.meta import onos
34from flog.meta import voltha
35
36## -----------------------------------------------------------------------
37## -----------------------------------------------------------------------
38def process():
39 '''Perform actions based on command line args.'''
40
41 argv = main_getopt.get_argv()
42 debug = argv['debug']
43 trace = argv['trace']
44
45 todos = []
46
47 ## -----------------------------
48 ## Accumulate tests by attribute
49 ## -----------------------------
50 for attr in argv['attr']:
51 if debug:
52 print('** ATTR: %s' % attr)
53 todos += voltha.Utils().get([attr])
54
55 ## ------------------------
56 ## Accumulate tests by type
57 ## ------------------------
58 for test_type in argv['type']:
59 if debug:
60 print('** TYPE: %s' % test_type)
61 todos += voltha.Utils().get([test_type])
62
63 ## ---------------------------------------
64 ## Append an explicit list of tests to run
65 ## ---------------------------------------
66 for incl in argv['incl']:
67 if debug:
68 print('** INCL: %s' % incl)
69 todos += [incl]
70
71 ## -------------------------------------
72 ## Filter results by substring or config
73 ## -------------------------------------
74 # if len(argv['excl']) > 1:
75 # for excl in argv['excl']:
76 # if any([excl in val for val in todos]):
77 # continue
78 #
79
80 todos = list(set(todos)) # unique
81
82 # -------------------------------------
83 # Err on the side of testing everything
84 # -------------------------------------
85 if len(todos) == 0:
86 todos += voltha.Utils().get(['all'])
87
88 for todo in todos:
89 print(todo)
90
91 return
92
93
94## -----------------------------------------------------------------------
95## -----------------------------------------------------------------------
96def main(argv_raw):
97 '''Here we go.'''
98
99 main_getopt.getopts(argv_raw)
100 process()
101 sys.exit(0)
102
103##----------------##
104##---] MAIN [---##
105##----------------##
106if __name__ == "__main__":
107 main(sys.argv[1:]) # NOSONAR
108
109# [EOF]