forked from Ericsson/codechecker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[server][fix] trim path prefix at store
The trim path prefix feature was broken during a previous refactoring this change fixes it and adds an additional functional test to detect if the feature is broken. Smaller refactoring was done to be more explicit which filepath is used where.
- Loading branch information
Gyorgy Orban
committed
Nov 6, 2020
1 parent
0a94cb2
commit a95a6d6
Showing
8 changed files
with
733 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# ------------------------------------------------------------------------- | ||
# | ||
# Part of the CodeChecker project, under the Apache License v2.0 with | ||
# LLVM Exceptions. See LICENSE for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ------------------------------------------------------------------------- | ||
|
||
"""Setup for the package tests.""" | ||
|
||
|
||
import multiprocessing | ||
import os | ||
import shutil | ||
|
||
from libtest import codechecker | ||
from libtest import env | ||
|
||
# Test workspace initialized at setup for report storage tests. | ||
TEST_WORKSPACE = None | ||
|
||
|
||
def setup_package(): | ||
"""Setup the environment for the tests then start the server.""" | ||
|
||
global TEST_WORKSPACE | ||
TEST_WORKSPACE = env.get_workspace('store_test') | ||
|
||
os.environ['TEST_WORKSPACE'] = TEST_WORKSPACE | ||
|
||
# Configuration options. | ||
codechecker_cfg = { | ||
'suppress_file': None, | ||
'skip_list_file': None, | ||
'check_env': env.test_env(TEST_WORKSPACE), | ||
'workspace': TEST_WORKSPACE, | ||
'checkers': [], | ||
'reportdir': os.path.join(TEST_WORKSPACE, 'reports'), | ||
'test_project': 'store_test' | ||
} | ||
|
||
# Start or connect to the running CodeChecker server and get connection | ||
# details. | ||
print("This test uses a CodeChecker server... connecting...") | ||
server_access = codechecker.start_or_get_server() | ||
server_access['viewer_product'] = 'store_test' | ||
codechecker.add_test_package_product(server_access, TEST_WORKSPACE) | ||
|
||
# Extend the checker configuration with the server access. | ||
codechecker_cfg.update(server_access) | ||
|
||
# Export the test configuration to the workspace. | ||
env.export_test_cfg(TEST_WORKSPACE, {'codechecker_cfg': codechecker_cfg}) | ||
|
||
|
||
def teardown_package(): | ||
"""Clean up after the test.""" | ||
|
||
# TODO: If environment variable is set keep the workspace | ||
# and print out the path. | ||
global TEST_WORKSPACE | ||
|
||
check_env = env.import_test_cfg(TEST_WORKSPACE)[ | ||
'codechecker_cfg']['check_env'] | ||
codechecker.remove_test_package_product(TEST_WORKSPACE, check_env) | ||
|
||
print("Removing: " + TEST_WORKSPACE) | ||
shutil.rmtree(TEST_WORKSPACE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Makefile to build and analyze the test files required | ||
# for the store update tests. | ||
|
||
build: | ||
$(CXX) divide_zero.cpp -o divide_zero | ||
|
||
clean: | ||
rm -rf divide_zero | ||
|
||
# Using relative path to the source files | ||
# it is easier to prefix them with the temporary | ||
# directory during test preparation. | ||
analyze: | ||
clang --analyze -I. divide_zero.cpp --analyzer-output plist-multi-file \ | ||
-o divide_zero.plist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// ------------------------------------------------------------------------- | ||
// Part of the CodeChecker project, under the Apache License v2.0 with | ||
// LLVM Exceptions. See LICENSE for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// ------------------------------------------------------------------------- | ||
|
||
// core.DivideZero (C, C++, ObjC) | ||
// Check for division by zero. | ||
#include "lib.h" | ||
|
||
void test1(int z) { | ||
if (z == 0) | ||
int x = 1 / z; // warn | ||
} | ||
|
||
void test2(){ | ||
int x = 1; | ||
div(x); | ||
} |
Oops, something went wrong.