Пример #1
0
def action_gnb_cu_pytest(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd <= 1 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cu')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            xprint_new_line('\tshould build firstly')
            return {'flag': True, 'new_input_cmd': ''}
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CU_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-linsee-setup.sh && '
        system_cmd += 'cd ' + build_dir + ' && '
        system_cmd += 'make sct'
        if num_cmd == 1:
            system_cmd += ' testfilter=' + cmds[0]
        xprint_new_line('')
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cu_pytest_help()
Пример #2
0
def action_gnb_cprt_ut(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd <= 1 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cprt')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            xprint_new_line('\tshould build firstly')
            return {'flag': True, 'new_input_cmd': ''}
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CPRT_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-setup.sh && '
        system_cmd += 'export BUILD_DIR=' + build_dir + ' && '
        system_cmd += 'export DEBUG_LOG=1 && '
        system_cmd += 'cd ' + build_dir + ' && '
        if num_cmd == 1:
            system_cmd += 'GTEST_FILTER=*' + cmds[0] + '* '
        system_cmd += 'ninja ut'
        xprint_new_line('')
        xprint_head(system_cmd)
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cprt_ut_help()
Пример #3
0
def action_replace(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd > 0 and num_cmd <= 2 and key == XKey.ENTER:
        old_string = cmds[0]
        new_string = ''
        if num_cmd == 2:
            new_string = cmds[1]

        xprint_new_line('')
        for root, dirs, files in os.walk('./'):
            for item in files:
                path = os.path.join(root, item)
                #print(os.path.join(root, item))
                shutil.copy(path, '{}.orig'.format(path))
                new_cmd = 'sed -ri \'s/' + old_string + '/' + new_string + '/g\' ' + path
                if os.path.exists('/usr/bin/colordiff'):
                    new_cmd += ' && colordiff -u ' + line + '.orig' + ' ' + line
                elif os.path.exists('/usr/bin/diff'):
                    new_cmd += ' && diff -u ' + line + '.orig' + ' ' + line
                os.system(new_cmd)
                os.unlink('{}/{}.orig'.format(repo_dir, line))
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_replace_help()
Пример #4
0
def statictis_messages(messages):
    for message in messages:
        xprint_head('statictis ' + message['message'])
        statictis_messages_count(message['message'])
        if message['sub'] == False:
            continue
        message['ids'] = statictis_messages_with_id(message['message'], message['sub_string'])
Пример #5
0
def action_gnb_cpnrt_ttcn(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd <= 2 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cpnrt')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            os.makedirs(build_dir)
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CPNRT_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-setup.sh && '
        system_cmd += 'cd ' + build_dir + ' && '
        system_cmd += 'cmake ' + repo_dir + '/cplane/CP-NRT -DBUILD_TTCN3_SCT=ON && '
        system_cmd += 'make sct_run_cp_nrt -j$(nproc) -l$(nproc) '
        if num_cmd >= 1:
            system_cmd += 'SCT_TEST_PATTERNS=' + cmds[0]
        if num_cmd == 2:
            system_cmd += ' SCT_TTCN3_REPEAT_COUNT=' + cmds[1]
        xprint_new_line('')
        xprint_head(system_cmd)
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cpnrt_ttcn_help()
Пример #6
0
def action_gnb_cprt_pytest(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd <= 1 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cprt')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            xprint_new_line('\tshould build firstly')
            return {'flag': True, 'new_input_cmd': ''}
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CPRT_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-setup.sh && '
        system_cmd += 'export BUILD_DIR=' + build_dir + ' && '
        if num_cmd == 0:
            system_cmd += 'cd ' + build_dir + ' && '
            system_cmd += '../gnb/buildscript/CP-RT/run sct_run'
        elif num_cmd == 1:
            system_cmd += 'cd ' + repo_dir + '/cplane/CP-RT/CP-RT/SCT/Pytest/ && '
            system_cmd += './cprt-pytest ' + cmds[0]
        xprint_new_line('')
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cprt_pytest_help()
Пример #7
0
def action_gnb_cprt_build(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd == 0 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cprt')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            os.makedirs(build_dir)
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CPRT_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-setup.sh && '
        system_cmd += 'export BUILD_DIR=' + build_dir + ' && '
        system_cmd += 'cd ' + build_dir + ' && '
        system_cmd += 'cmake -GNinja -DBUILD_TESTS=ON ' + repo_dir + '/cplane/CP-RT/CP-RT/ && '
        system_cmd += 'ninja'
        xprint_new_line(system_cmd)
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cprt_build_help()
Пример #8
0
def action_gnb_cu_build(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd == 0 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cu')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            os.makedirs(build_dir)
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CU_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-linsee-setup.sh && '
        system_cmd += 'cd ' + build_dir + ' && '
        system_cmd += 'cmake --version && echo $PATH && '
        system_cmd += 'cmake ' + repo_dir + '/cplane && '
        system_cmd += 'make -j$(nproc)'
        xprint_new_line('')
        xprint_head(system_cmd)
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cu_build_help()
Пример #9
0
def find_and_show_id_map():
    xprint_head('finding ues...')
    create_grep_id_output()
    count = 0
    id_map_history = []
    id_map = {}
    ueidcus = []
    try:
        fw = open(XConst.ID_MAP_FILE, 'w')
        fr = open(XConst.GREP_ID_FILE, 'r')
        write_head_in_id_map_file(fw)
        for read_line in fr:
            find_ueidcu(read_line, ueidcus)

            is_find, id_map_output = find_id_map(read_line, id_map_history)
            if not is_find:
                continue
            count = add_id_map(id_map_output, id_map, count)

        ueidcus = sorted(ueidcus, key=lambda d: int(d))
        show_ueidcu(ueidcus)

        sorted_list = format_id_map(ueidcus, id_map)
        write_id_map(fw, sorted_list)

    finally:
        if fw:
            fw.close()
        if fr:
            fr.close()
    xprint_head('id map ( ' + str(count) + ' ) is in ' + XConst.ID_MAP_FILE + '\n')

    return ueidcus
Пример #10
0
def show_match_string(string, string_list):
    flag = True
    for string_item in string_list:
        if len(string) == 0 or re.match(string, string_item):
            if flag:
                flag = False
                print ('\r')
            xprint_head('\t{}'.format(string_item), XPrintStyle.BLUE)
Пример #11
0
def show_ueidcu(ueidcus):
    xprint_head('[UEIDCU] ( ' + str(len(ueidcus)) + ' )', XPrintStyle.YELLOW)
    id_str = ''
    for ueid in ueidcus:
        id_str = id_str + str(ueid) + ','
    if len(id_str) > 0 and id_str[-1] == ',':
        id_str = id_str[:-1]
    xprint_head(id_str + '\n')
Пример #12
0
def show_remove_result(result):
    xprint_new_line()
    if result == None or len(result) == 0:
        xprint_head('\tno any login history to remove')
        return
    for item in result:
        show_info = '\tremove: name=' + item['name'] + ' ip=' + item[
            'ip'] + ' user='******'user'] + ' password='******'password']
        xprint_head(show_info)
Пример #13
0
def action_gnb_cu_ut(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd <= 1 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cu')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            xprint_new_line('\tshould build firstly')
            return {'flag': True, 'new_input_cmd': ''}
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CU_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-linsee-setup.sh && '
        system_cmd += 'cd ' + build_dir + ' && '
        system_cmd += 'make -j$(nproc) '
        if num_cmd == 1:
            uts = os.popen('cd ' + build_dir + ' && ' + 'ls ./bin | grep -w ' +
                           cmds[0])
            line = uts.readline()
            uts.close()
            if line:
                system_cmd += '&& ./bin/' + cmds[0]
            else:
                system_cmd += '&& '
                xprint_new_line('Searching ' + cmds[0] + ' ...')
                uts = os.popen('cd ' + build_dir + ' && ' + 'grep -lr ' +
                               cmds[0] + ' ./bin/')
                line = uts.readline()
                if not line:
                    xprint_new_line('\tcan not find case include ' + cmds[0])
                    return {'flag': True, 'new_input_cmd': ''}
                while line:
                    system_cmd += 'GTEST_FILTER=*' + cmds[
                        0] + '* ' + line.strip() + ' && '
                    line = uts.readline()
                uts.close()
                system_cmd = system_cmd[0:-3]
        else:
            system_cmd += 'ut'
            xprint_new_line('')
        xprint_head(system_cmd)
        #os.system('find ' + repo_dir + ' -name ut_main.cpp | xargs sed -i \"s/spdlog::level::off/spdlog::level::trace/\"')
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cu_ut_help()
Пример #14
0
def action_gnb_codeformat(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd <= 1 and key == XKey.ENTER:
        head_offset = 0
        if num_cmd == 1:
            if not cmds[0].isdigit():
                xprint_new_line('\tshould be number, ' + cmds[0] + ' is wrong')
                return {'flag': True, 'new_input_cmd': ''}
            head_offset = int(cmds[0])

        repo_dir, _, _ = get_gnb_dirs('')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(XConst.CLANG_FORMAT):
            xprint_new_line('\tclang-format command is not found')
            return {'flag': True, 'new_input_cmd': ''}
        system_cmd = 'cd ' + repo_dir + ' && '
        system_cmd += XConst.CLANG_FORMAT
        system_cmd += ' -style=file '
        f = os.popen('cd ' + repo_dir +
                     ' && git diff --stat --name-only HEAD~' +
                     str(head_offset))
        line = f.readline().strip()
        xprint_new_line('')
        while line:
            line = repo_dir + '/' + line
            file_ext = os.path.splitext(line)
            if len(file_ext) <= 1 or file_ext[1] not in ('.hpp', '.cpp', '.h',
                                                         '.c', '.cc'):
                line = f.readline().strip()
                continue
            if not os.path.exists(line):
                line = f.readline().strip()
                continue
            shutil.copy(line, '{}.orig'.format(line))
            new_cmd = system_cmd + ' -i ' + line
            if os.path.exists('/usr/bin/colordiff'):
                new_cmd += ' && colordiff -u ' + line + '.orig' + ' ' + line
            elif os.path.exists('/usr/bin/diff'):
                new_cmd += ' && diff -u ' + line + '.orig' + ' ' + line
            os.system(new_cmd)
            os.unlink('{}.orig'.format(line))
            line = f.readline().strip()
        f.close()
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_codeformat_help()
Пример #15
0
def statictis_2_messages_diff(message1, ids1, message2, ids2):
    diff_ids = []
    xprint_head('len of ids1 is ' + str(len(ids1)) + ', len of ids2 is ' + str(len(ids2)))
    for id1 in ids1:
        find_flag = False
        for id2 in ids2:
            if id1 == id2:
                #xprint_head('id1 is ' + id1 + ' id2 is ' + id2)
                find_flag = True
                break
        if find_flag == False:
            diff_ids.append(id1)
    xprint_head(diff_ids)
Пример #16
0
def action_gnb_clone(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd == 0 and key == XKey.ENTER:
        xprint_new_line('')
        os.system('git clone ' + XConst.GNB_REPO)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_clone()
Пример #17
0
def show_install_help():
    xprint_new_line('\t# install [PATH]', XPrintStyle.YELLOW)
    xprint_head('\tExample 1: # install')
    xprint_head('\t           -> install ' + XConst.PYFILE_NAME +
                ' in /usr/bin/ as default')
    xprint_head('\tExample 2: # install /bin')
    xprint_head('\t           -> install ' + XConst.PYFILE_NAME + ' in /bin')
Пример #18
0
def sort_contents_in_file(path, cpue_dir, ueidcu):
    sorted_path = path + "_sorted"
    time_content_map = {}
    thread_ids = {}
    fr = open(path, 'r')
    fw = open(sorted_path, 'w')
    xprint_head('start to sort ' + path)
    for read_line in fr:
        line = read_line.strip()
        if line == '':
            continue
        #print('line is ' + line)
        obj = re.search(r'.+<([0-9:.\-TZ]+)>.+', line)
        if not obj:
            #print('should happen error in line ' + line)
            continue
        time = obj.group(1)
        #print('time is ' + time)
        if time in time_content_map:
            #print('meet same time ' + time)
            #print('new same time line is ' + line)
            time_content_map[time].append([line])
        else:
            time_content_map[time] = [[line]]

        obj = re.search(r'.*\[cp_ue\]\[([0-9]+)\].*', line)
        if not obj:
            continue
        thread_id = obj.group(1)
        if not thread_id in thread_ids:
            cpue_file = cpue_dir + '/ueidcu_' + ueidcu + '_cpue_' + thread_id
            thread_ids[thread_id] = open(cpue_file, 'w')

    sorted_list = sorted(time_content_map.items(), key=lambda d: d[0])

    for item in sorted_list:
        for lines in item[1]:
            #print('lines is ' + lines)
            for line in lines:
                fw.write(line.strip() + '\n')
                obj = re.search(r'.*\[cp_ue\]\[([0-9]+)\].*', line)
                if not obj:
                    continue
                thread_id = obj.group(1)
                thread_ids[thread_id].write(line.strip() + '\n')

    fr.close()
    fw.close()
    for value in thread_ids.values():
        value.close()
Пример #19
0
def show_gnb_cu_mt_help():
    xprint_new_line('\t# gnb cu mt [PATTERN]', XPrintStyle.YELLOW)
    xprint_head('\tExample 1: # gnb cu mt')
    xprint_head('\t           -> run all mt cases for cu')
    xprint_head('\tExample 2: # gnb cu mt TeidHelperTests')
    xprint_head(
        '\t           -> run mt cases that name contains TeidHelperTests for cu'
    )
Пример #20
0
def show_gnb_cpnrt_ut_help():
    xprint_new_line('\t# gnb cpnrt ut [PATTERN]', XPrintStyle.YELLOW)
    xprint_head('\tExample 1: # gnb cpnrt ut')
    xprint_head('\t           -> run all ut cases for cpnrt')
    xprint_head('\tExample 2: # gnb cpnrt ut TeidHelperTests')
    xprint_head(
        '\t           -> run ut cases that name contains TeidHelperTests for cpnrt'
    )
Пример #21
0
def show_install_help():
    xprint_new_line('\t# cd [ACTION]')
    xprint_head('\tExample 1: # cd install')
    xprint_head('\t           -> only support one ACTION as install currently')
    xprint_head(
        '\t           -> it will install a command named xcd which can be used directly in console'
    )
    xprint_head('\t           -> detail for xcd to be continued')
Пример #22
0
def show_gnb_cpnrt_pytest_help():
    xprint_new_line('\t# gnb cpnrt pytest [PATTERN]', XPrintStyle.YELLOW)
    xprint_head('\tExample 1: # gnb cpnrt pytest')
    xprint_head('\t           -> run all pytest cases for cpnrt')
    xprint_head('\tExample 2: # gnb cpnrt pytest test_case_name')
    xprint_head(
        '\t           -> run pytest cases that name contains test_case_name for cpnrt'
    )
Пример #23
0
def parse_function(full_line, fw):
    new_line = re.sub(r'[ ]{2,}', ' ', full_line)
    new_line = re.sub(r' ,', ',', new_line)
    new_line = re.sub(r', ', ',', new_line)
    #xprint_head(new_line)
    obj = re.match(r'(.+) (\w+)\((.*)\)(.*);$', new_line)
    if not obj:
        return

    mock_line = 'MOCK_METHOD('
    mock_line = mock_line + obj.group(1) + ', ' + obj.group(2)
    mock_line = mock_line + ', (' + obj.group(3) + ')'
    func_types = ''
    if re.search(r'const', obj.group(4)):
        mock_line = mock_line + ', (const)'
    mock_line = mock_line + ');'
    xprint_head(mock_line)
    fw.write(mock_line + '\n')
Пример #24
0
def parse_commits_output(output):
    commits_num = len(output)
    xprint_head('\nthere are totally ' + str(commits_num) + ' commits\n')
    df = pandas.DataFrame()
    for line in output:
        #xprint_head(line);
        parts = line.split(',', 3)
        if len(parts) >= 4:
            result = {'date': '-', 'author': '-', 'message': '-'}
            commit_id = re.sub('\* ', '', parts[0])
            result['date'] = parts[1]
            result['author'] = parts[2]
            result['message'] = parts[3]
            new_df = pandas.DataFrame(result, index=[commit_id])
            df = df.append(new_df)

    xprint_head(df)
    df.to_csv('git_commits_final_result.csv')
Пример #25
0
def action_gnb_cpnrt_ut(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd <= 1 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, build_dir = get_gnb_dirs('cpnrt')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if not os.path.exists(build_dir):
            xprint_new_line('\tshould build firstly')
            return {'flag': True, 'new_input_cmd': ''}
        runtime_dir = build_dir + '/runtime_output'
        library_dir = build_dir + '/libs'
        tests_dir = build_dir + '/tests_output'
        ut_output_file = tests_dir + '/ut.xml'
        env_path = os.getenv('PATH')
        env_prefix_type = os.getenv('PREFIX_TYPE')
        if not env_prefix_type:
            env_prefix_type = XConst.CPNRT_PREFIX_TYPE
        system_cmd = ''
        if not re.search('sdk5g.+prefix_root_' + env_prefix_type, env_path):
            system_cmd += 'source ' + sdk5g_dir + '/prefix_root_' + env_prefix_type + '/environment-setup.sh && '
        system_cmd += 'cd ' + build_dir + ' && '
        system_cmd += 'cmake --warn-uninitialized -Werror=dev'
        system_cmd += ' -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + library_dir
        system_cmd += ' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=' + runtime_dir
        system_cmd += ' -DCMAKE_TEST_OUTPUT_DIRECTORY=' + tests_dir
        system_cmd += ' -DBUILD_TESTS=ON -DBUILD_TTCN3_SCT=OFF'
        system_cmd += ' ' + repo_dir + '/cplane/CP-NRT/ && '
        system_cmd += 'make -j$(nproc) cp-nrt_ut && '
        system_cmd += 'export GTEST_OUTPUT=xml:' + ut_output_file + ' && '
        if num_cmd == 1:
            system_cmd += ' GTEST_FILTER=*' + cmds[0] + '* '
        system_cmd += runtime_dir + '/cp-nrt_ut'
        xprint_new_line('')
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cpnrt_build_help()
Пример #26
0
def find_all_ueidcus(ueidcus):
    os.system('mkdir -p ' + XConst.UEIDCUS_DIR)
    ueidcu_dir = XConst.UEIDCUS_DIR + '/ueidcus'
    ueidcu_cpue_dir = XConst.UEIDCUS_DIR + '/cpues'
    for ueidcu in ueidcus:
        ueidcu_file = ueidcu_dir + '/ueidcu_' + ueidcu
        if os.path.exists(ueidcu_file):
            continue
        xprint_head('start to collect ' + ueidcu_file)
        command = 'mkdir -p ' + ueidcu_dir + ' ' + ueidcu_cpue_dir + ' && '
        command = command + 'grep -nwri \"ueidcu:' + ueidcu + '\" ' + XConst.GREP_ID_FILE
        command = command + ' > ' + ueidcu_file + ' &'
        os.system(command)
        #child = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
        #child.communicate()

    for ueidcu in ueidcus:
        ueidcu_file = ueidcu_dir + '/ueidcu_' + ueidcu
        if not os.path.exists(ueidcu_file):
            continue
        sort_contents_in_file(ueidcu_file, ueidcu_cpue_dir, ueidcu)
Пример #27
0
def show_lines_statistic(match_list, match_map, max_line_length):
    print_line = 'FILE' + ' ' * (max_line_length - len(
        'FILE')) + '    ' + 'LINES' + ' ' * (10 - len('LINES')) + '    DEPTH'
    xprint_head(print_line + '\n')
    path = match_list[0]['path']
    print_line = path + ' ' * (max_line_length - len(path)) + '    '
    print_line = print_line + str(
        match_map[path]) + ' ' * (10 - len(str(match_map[path])))
    print_line = print_line + '    ' + str(match_list[0]['depth'])
    xprint_head(format_color_string(print_line, XPrintStyle.GREEN_U))
    for item in match_list[1:]:
        path = item['path']
        print_line = item['print']
        print_line = print_line + ' ' * (max_line_length -
                                         len(print_line)) + '    '
        if os.path.isfile(path):
            print_line = print_line + str(
                item['lines']) + ' ' * (10 - len(str(item['lines'])))
        elif os.path.isdir(path):
            print_line = print_line + str(
                match_map[path]) + ' ' * (10 - len(str(match_map[path])))
        print_line = print_line + '    ' + str(item['depth'])
        if os.path.isdir(path):
            print_line = format_color_string(print_line, XPrintStyle.BLUE)
        xprint_head(print_line)
Пример #28
0
def find_error_logs():
    xprint_head('finding error logs...')
    create_grep_error_output()
    xprint_head('collecting similar error logs...')
    exist_lines = collect_similar_logs(XConst.GREP_ERROR_FILE)
    show_and_write_similar_logs(XConst.GREP_ERROR_FILE + '_similar', 'ERROR', exist_lines)
    xprint_head(' ')
Пример #29
0
def find_warn_logs():
    xprint_head('finding warn logs...')
    create_grep_warn_output()
    xprint_head('collecting similar warn logs...')
    exist_lines = collect_similar_logs(XConst.GREP_WARN_FILE)
    show_and_write_similar_logs(XConst.GREP_WARN_FILE + '_similar', 'WARN', exist_lines)
    xprint_head(' ')
Пример #30
0
def action_gnb_cpnrt_sdk(cmds, key):
    num_cmd = len(cmds)
    if cmds[num_cmd - 1] == '':
        del cmds[num_cmd - 1]
        num_cmd -= 1

    if num_cmd == 0 and key == XKey.ENTER:
        repo_dir, sdk5g_dir, _ = get_gnb_dirs('cpnrt')
        if not repo_dir:
            xprint_new_line('\tNot a git repository')
            return {'flag': True, 'new_input_cmd': ''}
        if os.path.exists(sdk5g_dir):
            xprint_new_line('\tsdk5g is already exits, should remove firstly')
            return {'flag': True, 'new_input_cmd': ''}
        system_cmd = 'export SDK5G_DIR=' + sdk5g_dir + ' && '
        system_cmd += repo_dir + '/' + XConst.CPNRT_SDK_SHELL + ' -t all'
        xprint_new_line('')
        os.system(system_cmd)
        xprint_head('')
        return {'flag': True, 'new_input_cmd': ''}

    show_gnb_cpnrt_sdk_help()