Skip to content

Commit

Permalink
Fix reviewer comments in #11590
Browse files Browse the repository at this point in the history
  • Loading branch information
Mab879 committed Feb 15, 2024
1 parent 4951763 commit 45cb7a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,4 @@ endmacro()

cce_avail_check("rhel-all" "rhel7,rhel8,rhel9" "${CMAKE_SOURCE_DIR}/shared/references/cce-redhat-avail.txt")
cce_avail_check("sle12" "sle12" "${CMAKE_SOURCE_DIR}/shared/references/cce-sle12-avail.txt")
cce_avail_check("sle15" "sle15" "${CMAKE_SOURCE_DIR}/shared/references/cce-sle12-avail.txt")
cce_avail_check("sle15" "sle15" "${CMAKE_SOURCE_DIR}/shared/references/cce-sle15-avail.txt")
18 changes: 9 additions & 9 deletions tests/cces-removed.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#! /usr/bin/python3
#!/usr/bin/python3

import argparse
import json
import os
from typing import Set
import sys
from typing import Set

SSG_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
JSON_PATH = os.path.join(SSG_ROOT, "build", "rule_dirs.json")
Expand All @@ -17,7 +17,7 @@ def _parse_args() -> argparse.Namespace:
"run.")
parser.add_argument('-p', '--products', required=True,
help='Comma separated list (no spaces) of products to check')
parser.add_argument('-l', '--cee-list', type=str, required=True,
parser.add_argument('-l', '--cce-list', type=str, required=True,
help='Path to cce avail list')
parser.add_argument('-j', '--json', type=str, default=JSON_PATH,
help='Path to rule_dirs.json file')
Expand All @@ -26,23 +26,23 @@ def _parse_args() -> argparse.Namespace:
return parser.parse_args()


def _process_rule(cces_in_use, products, rule_obj):
def _process_rule(cces_in_use: Set[str], products: str, rule_obj: dict):
for identifier_key, identifier_value in rule_obj['identifiers'].items():
for product in products.split(","):
if identifier_key.endswith(product):
cces_in_use.add(identifier_value)


def _get_cces_in_use(data, products) -> Set[str]:
def _get_cces_in_use(data: dict, products: str) -> Set[str]:
cces_in_use: Set[str] = set()
for rule_id, rule_obj in data.items():
for _, rule_obj in data.items():
_process_rule(cces_in_use, products, rule_obj)
return cces_in_use


def _get_avail_cces(args) -> Set[str]:
def _get_avail_cces(cce_list: str) -> Set[str]:
avail_cces: Set[str] = set()
with open(args.cee_list) as f:
with open(cce_list) as f:
for line in f.readlines():
avail_cces.add(line.strip())
return avail_cces
Expand All @@ -59,7 +59,7 @@ def main():
print(f"Test is useless, no CCEs were found for products in {','.join(products)}")
exit(2)

avail_cces = _get_avail_cces(args)
avail_cces = _get_avail_cces(args.cce_list)

not_removed = avail_cces.intersection(cces_in_use)
if len(not_removed) != 0:
Expand Down

0 comments on commit 45cb7a5

Please sign in to comment.