Skip to content

Commit 3d0e800

Browse files
authored
Merge pull request ERGO-Code#2295 from ERGO-Code/valgrind-ipx
valgrind tests
2 parents d4b10be + 14e7a68 commit 3d0e800

File tree

3 files changed

+118
-6
lines changed

3 files changed

+118
-6
lines changed

.github/workflows/valgrind.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: valgrind
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
unit_tests:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest]
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install Valgrind
16+
run: sudo apt-get update && sudo apt-get install valgrind
17+
18+
- name: Create Build Environment
19+
run: cmake -E make_directory ${{runner.workspace}}/build
20+
21+
- name: Configure CMake
22+
shell: bash
23+
working-directory: ${{runner.workspace}}/build
24+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DALL_TESTS=ON
25+
26+
- name: Build
27+
working-directory: ${{runner.workspace}}/build
28+
shell: bash
29+
run: |
30+
cmake --build . --parallel
31+
32+
- name: Test
33+
working-directory: ${{runner.workspace}}/build
34+
shell: bash
35+
run: |
36+
valgrind \
37+
--leak-check=full \
38+
--show-leak-kinds=all \
39+
--track-origins=yes \
40+
-s \
41+
./bin/unit_tests \
42+
2>&1 | tee logfile
43+
44+
- name: Check log for Errors
45+
working-directory: ${{runner.workspace}}/build
46+
shell: bash
47+
run: |
48+
cat logfile
49+
OUTPUT='ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)'
50+
if grep -q "$OUTPUT" logfile; then
51+
exit 0
52+
fi
53+
exit 1
54+
55+
instance_tests:
56+
runs-on: ${{ matrix.os }}
57+
strategy:
58+
matrix:
59+
os: [ubuntu-latest]
60+
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Install Valgrind
65+
run: sudo apt-get update && sudo apt-get install valgrind
66+
67+
- name: Create Build Environment
68+
run: cmake -E make_directory ${{runner.workspace}}/build
69+
70+
- name: Configure CMake All
71+
shell: bash
72+
working-directory: ${{runner.workspace}}/build
73+
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DALL_TESTS=ON
74+
75+
- name: Build All
76+
working-directory: ${{runner.workspace}}/build
77+
shell: bash
78+
run: |
79+
cmake --build . --parallel
80+
81+
- name: Test
82+
working-directory: ${{runner.workspace}}/build
83+
shell: bash
84+
run: |
85+
valgrind \
86+
--leak-check=full \
87+
--show-leak-kinds=all \
88+
--track-origins=yes \
89+
-s \
90+
ctest -E unit.* \
91+
--timeout 1000 \
92+
--output-on-failure \
93+
2>&1 | tee logfile2
94+
95+
- name: Check log for Errors
96+
working-directory: ${{runner.workspace}}/build
97+
shell: bash
98+
run: |
99+
cat logfile2
100+
OUTPUT='ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)'
101+
if grep -q "$OUTPUT" logfile2; then
102+
exit 0
103+
fi
104+
exit 1

check/TestIpx.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "lp_data/HighsStatus.h"
99
#include "parallel/HighsParallel.h"
1010

11+
#include "Highs.h"
12+
1113
// Example for using IPX from its C++ interface. The program solves the Netlib
1214
// problem afiro.
1315

@@ -45,6 +47,7 @@ TEST_CASE("test-ipx", "[highs_ipx]") {
4547
ipx::Parameters parameters;
4648
if (!dev_run) parameters.display = 0;
4749
parameters.highs_logging = false;
50+
parameters.timeless_log = false;
4851
lps.SetParameters(parameters);
4952

5053
// Solve the LP.
@@ -87,4 +90,8 @@ TEST_CASE("test-ipx", "[highs_ipx]") {
8790
REQUIRE(fabs(ipx_col_value[11] - 339.9) < 1);
8891

8992
(void)(info); // surpress unused variable.
93+
94+
// hack to reset global scheduler
95+
Highs h;
96+
h.resetGlobalScheduler(true);
9097
}

check/TestPresolve.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,10 @@ HighsStatus zeroCostColSing() {
258258
assert(status == HighsStatus::kOk);
259259

260260
status = highs.run();
261-
return status;
262261

263262
highs.resetGlobalScheduler(true);
263+
264+
return status;
264265
}
265266

266267
// handled by doubleton equality
@@ -317,9 +318,9 @@ HighsStatus colSingDoubletonEquality() {
317318
assert(status == HighsStatus::kOk);
318319

319320
status = highs.run();
320-
return status;
321321

322322
highs.resetGlobalScheduler(true);
323+
return status;
323324
}
324325

325326
HighsStatus colSingDoubletonInequality() {
@@ -375,9 +376,9 @@ HighsStatus colSingDoubletonInequality() {
375376
assert(status == HighsStatus::kOk);
376377

377378
status = highs.run();
378-
return status;
379379

380380
highs.resetGlobalScheduler(true);
381+
return status;
381382
}
382383

383384
// handled by doubleton equality
@@ -414,9 +415,9 @@ HighsStatus twoColSingDoubletonEquality() {
414415
assert(status == HighsStatus::kOk);
415416

416417
status = highs.run();
417-
return status;
418418

419419
highs.resetGlobalScheduler(true);
420+
return status;
420421
}
421422

422423
// handled by special case.
@@ -454,9 +455,9 @@ HighsStatus twoColSingDoubletonInequality() {
454455

455456
highs.run();
456457
status = highs.run();
457-
return status;
458458

459459
highs.resetGlobalScheduler(true);
460+
return status;
460461
}
461462

462463
// No commas in test case name.
@@ -543,9 +544,9 @@ HighsStatus issue425() {
543544
assert(status == HighsStatus::kOk);
544545

545546
status = highs.run();
546-
return status;
547547

548548
highs.resetGlobalScheduler(true);
549+
return status;
549550
}
550551

551552
TEST_CASE("presolve-issue-425", "[highs_test_presolve]") {

0 commit comments

Comments
 (0)