Skip to content

Commit 866bedf

Browse files
committed
remove coverage stuff from build script
1 parent 77da3c5 commit 866bedf

File tree

5 files changed

+86
-54
lines changed

5 files changed

+86
-54
lines changed

CMakeLists.txt

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@
1616

1717
cmake_minimum_required(VERSION 3.30)
1818

19-
project(scl VERSION 0.1.0 DESCRIPTION "Secure Computation Library" LANGUAGES CXX)
19+
project(scl VERSION 0.2.0 DESCRIPTION "Secure Computation Library" LANGUAGES CXX)
2020

2121
option(SCL_BUILD_TESTS
2222
"Build tests for SCL"
2323
ON)
2424

25-
option(
26-
SCL_BUILD_TEST_WITH_COVERAGE
27-
"Build test with coverage. Implies SCL_BUILD_TESTS=ON"
28-
OFF)
29-
3025
option(
3126
SCL_BUILD_WITH_ADDRESS_SANITIZATION
3227
"Buid SCL with -fsanitize=address. Implies SCL_BUILD_TESTS=ON"
@@ -49,11 +44,6 @@ option(
4944
"Generate compile_commands.json"
5045
ON)
5146

52-
if(SCL_BUILD_TEST_WITH_COVERAGE)
53-
set(SCL_BUILD_TESTS ON)
54-
set(CMAKE_BUILD_TYPE RelWithDebInfo)
55-
endif()
56-
5747
find_library(GMP gmp libgmp REQUIRED)
5848

5949
set(SCL_HEADERS "${CMAKE_SOURCE_DIR}/include")
@@ -81,7 +71,7 @@ set(SCL_SOURCE_FILES
8171
src/scl/net/tcp/network.cc
8272

8373
src/scl/simulation/event.cc
84-
src/scl/simulation/network_description.cc
74+
src/scl/simulation/params.cc
8575
src/scl/simulation/context.cc
8676
src/scl/simulation/transport.cc
8777
src/scl/simulation/channel.cc
@@ -101,25 +91,20 @@ target_compile_options(scl PUBLIC "-Wall")
10191
target_compile_options(scl PUBLIC "-Wextra")
10292
target_compile_options(scl PUBLIC "-pedantic")
10393

104-
## indicates that SCL is being built with some extra flags that will
105-
## produce a non-optimal build.
106-
set(SCL_SPECIAL_BUILD OFF)
94+
if(CMAKE_BUILD_TYPE MATCHES Release)
95+
set(SCL_SPECIAL_BUILD OFF)
96+
else()
97+
## indicates that SCL is being built with some extra flags that will
98+
## produce a non-optimal build.
99+
set(SCL_SPECIAL_BUILD ON)
100+
endif()
107101

108102
if(SCL_BUILD_WITH_ADDRESS_SANITIZATION)
109103
target_compile_options(scl PUBLIC "-fsanitize=address")
110104
target_link_libraries(scl PUBLIC "-fsanitize=address")
111105
set(SCL_SPECIAL_BUILD ON)
112106
endif()
113107

114-
if(SCL_BUILD_TEST_WITH_COVERAGE)
115-
target_compile_options(scl PUBLIC "-O0")
116-
target_compile_options(scl PUBLIC "-g")
117-
target_compile_options(scl PUBLIC "--coverage")
118-
target_compile_options(scl PUBLIC "-fno-inline")
119-
target_link_libraries(scl PUBLIC gcov)
120-
set(SCL_SPECIAL_BUILD ON)
121-
endif()
122-
123108
if (SCL_SPECIAL_BUILD MATCHES OFF)
124109
target_compile_options(scl PRIVATE "-O3")
125110

include/scl/simulation/network_description.h renamed to include/scl/simulation/params.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,66 @@
2020
#include <cstddef>
2121
#include <random>
2222
#include <unordered_map>
23+
#include <variant>
2324

2425
#include "scl/simulation/channel_id.h"
2526

2627
namespace scl {
2728

29+
class ChannelDesc final {
30+
public:
31+
ChannelDesc createDet(std::size_t bandwidth, std::size_t latency) {
32+
return ChannelDesc(DetParams{bandwidth, latency});
33+
}
34+
ChannelDesc createProp(std::normal_distribution<> bandwidth,
35+
std::normal_distribution<> latency) {
36+
std::random_device rd{};
37+
std::mt19937 rg{rd()};
38+
return ChannelDesc(PropParams{rg, bandwidth, latency});
39+
}
40+
41+
std::size_t bandwidth();
42+
std::size_t latency();
43+
44+
private:
45+
struct DetParams final {
46+
std::size_t bandwidth;
47+
std::size_t latency;
48+
};
49+
50+
struct PropParams final {
51+
std::mt19937 rg;
52+
53+
std::normal_distribution<> bandwidth;
54+
std::normal_distribution<> latency;
55+
};
56+
57+
ChannelDesc(DetParams params) : m_params(params) {}
58+
ChannelDesc(PropParams params) : m_params(params) {}
59+
60+
std::variant<DetParams, PropParams> m_params;
61+
};
62+
63+
// TODO: Create a simplier, and more extensible network description. Potentially
64+
// shorten the name as well.
65+
//
66+
// The new object (interface shown below) should provide the "raw" link
67+
// bandwidth and latency on a given channel. I guess it is possible to
68+
// dynamically adjust the bandwidth of a channel depending on usage, but I think
69+
// that task is better done elsewhere (e.g., in the Transport).
70+
//
71+
// NetworkDesc:
72+
// std::size_t latency(ChannelId cid);
73+
// std::size_t bandwidth(ChannelId cid);
74+
//
75+
// ChannelDesc:
76+
// virtual std::size_t latency();
77+
// virtual std::size_t bandwidth();
78+
//
79+
// NetworkDesc is internally composed of a list of ChannelDesc. The definition
80+
// of ChannelDesc allows the user to either provide some constant value, or to
81+
// sample the value from a distribution.
82+
2883
/**
2984
* @brief Describes the characterists of a channel.
3085
*/

src/scl/simulation/network_description.cc renamed to src/scl/simulation/params.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
#include "scl/simulation/network_description.h"
19-
2018
#include <cmath>
2119
#include <cstddef>
2220
#include <limits>
2321
#include <unordered_map>
2422

2523
#include "scl/simulation/channel_id.h"
24+
#include "scl/simulation/params.h"
2625

2726
using namespace scl;
2827

test/CMakeLists.txt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,3 @@ target_link_libraries(scl_test
8787
PRIVATE pthread
8888
PRIVATE gmp)
8989
catch_discover_tests(scl_test)
90-
91-
if(SCL_BUILD_TEST_WITH_COVERAGE)
92-
93-
if (NOT SCL_GCOV_BIN)
94-
set(SCL_GCOV_BIN "gcov")
95-
endif()
96-
97-
## stuff that SCL uses, but which we are not interested in
98-
## generating coverage of.
99-
set(SCL_COVERAGE_EXCLUDES "")
100-
list(APPEND SCL_COVERAGE_EXCLUDES "'/usr/*'")
101-
list(APPEND SCL_COVERAGE_EXCLUDES "'${CMAKE_BINARY_DIR}/*'")
102-
list(APPEND SCL_COVERAGE_EXCLUDES "'${CMAKE_SOURCE_DIR}/test/*'")
103-
104-
add_custom_target(coverage
105-
COMMAND lcov --ignore-errors mismatch --gcov-tool ${SCL_GCOV_BIN} -d ${CMAKE_BINARY_DIR} -b ${CMAKE_BINARY_DIR} -z
106-
COMMAND lcov --ignore-errors mismatch --gcov-tool ${SCL_GCOV_BIN} -d ${CMAKE_BINARY_DIR} -b ${CMAKE_BINARY_DIR} -c -i -o cov.base
107-
COMMAND scl_test
108-
COMMAND lcov --ignore-errors mismatch --gcov-tool ${SCL_GCOV_BIN} -d ${CMAKE_BINARY_DIR} -b ${CMAKE_BINARY_DIR} -c -o cov.cap
109-
COMMAND lcov --ignore-errors mismatch --gcov-tool ${SCL_GCOV_BIN} -a cov.base -a cov.cap -o cov.total
110-
COMMAND wc -l cov.total
111-
COMMAND lcov --ignore-errors mismatch --gcov-tool ${SCL_GCOV_BIN} --remove cov.total ${SCL_COVERAGE_EXCLUDES} -o cov.info
112-
COMMAND genhtml --demangle-cpp --ignore-errors mismatch -o coverage cov.info
113-
114-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
115-
BYPRODUCTS cov.base cov.cap cov.total cov.info)
116-
117-
endif()

test/scl/simulation/test_params.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* SCL --- Secure Computation Library
2+
* Copyright (C) 2025 Anders Dalskov
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Affero General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include <catch2/catch_test_macros.hpp>
19+
20+
#include "scl/simulation/params.h"
21+

0 commit comments

Comments
 (0)