Skip to content

Commit 4965906

Browse files
authored
Add coverage to helio tests (romange#123)
Also add std:: to move calls. Signed-off-by: Roman Gershman <[email protected]>
1 parent 5401d29 commit 4965906

File tree

17 files changed

+54
-36
lines changed

17 files changed

+54
-36
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77
branches: [ master ]
88
workflow_dispatch:
9-
9+
1010
env:
1111
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
1212
BUILD_TYPE: Debug
@@ -20,12 +20,12 @@ jobs:
2020
strategy:
2121
matrix:
2222
# Test of these containers
23-
container: ["ubuntu-dev:20", "alpine-dev:latest"]
24-
compiler: [{cxx: g++, c: gcc}]
25-
cxx_flags: ["-Werror"]
2623
include:
2724
- container: "alpine-dev:latest"
2825
compiler: {cxx: clang++, c: clang}
26+
- container: "ubuntu-dev:20"
27+
compiler: {cxx: g++, c: gcc}
28+
cxx_flags: "-fprofile-arcs -ftest-coverage -Werror"
2929
timeout-minutes: 50
3030
container:
3131
image: ghcr.io/romange/${{ matrix.container }}
@@ -48,27 +48,42 @@ jobs:
4848
run: |
4949
uname -a
5050
ulimit -a
51+
5152
cat /proc/cpuinfo
5253
cmake -B ${{github.workspace}}/build \
5354
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
5455
-GNinja \
5556
-DCMAKE_C_COMPILER="${{matrix.compiler.c}}" \
5657
-DCMAKE_CXX_COMPILER="${{matrix.compiler.cxx}}" \
58+
-DCMAKE_CXX_FLAGS_DEBUG="${{matrix.cxx_flags}}" \
5759
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER_LAUNCHER=sccache
5860
- name: Build
5961
run: |
6062
cd ${{github.workspace}}/build
61-
63+
6264
ninja -k 5 base/all io/all strings/all util/all echo_server ping_iouring_server https_client_cli
6365
${SCCACHE_PATH} --show-stats
64-
66+
6567
- name: Test
6668
run: |
6769
cd ${{github.workspace}}/build
6870
GLOG_logtostderr=1 gdb -batch -ex "run" -ex "thread apply all bt" \
6971
./accept_server_test || true
7072
GLOG_logtostderr=1 GLOG_vmodule=proactor=1 ctest -V -L CI
7173
# ./proactor_test --gtest_filter=*Migrate --logtostderr --vmodule=proactor=2,uring_fiber_algo=1
74+
- name: Coverage
75+
if: matrix.compiler.cxx == 'g++'
76+
run: |
77+
lcov -c -d ${{github.workspace}}/build -o coverage.info
78+
lcov --remove coverage.info -o coverage.info '/usr/*' '*/_deps/*' '*/third_party/*'
79+
80+
- name: Upload coverage to Codecov
81+
if: matrix.compiler.cxx == 'g++'
82+
uses: codecov/codecov-action@v3
83+
with:
84+
files: ./coverage.info
85+
fail_ci_if_error: true
86+
7287
build-macos:
7388
runs-on: macos-latest
7489
timeout-minutes: 30
@@ -79,7 +94,7 @@ jobs:
7994
cmake --version
8095
gcc-13 --version
8196
uname -a
82-
- name: Configure CMake
97+
- name: Configure CMake
8398
run: |
8499
cmake -B ${{github.workspace}}/build \
85100
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ genfiles/*
1111
third_party
1212
*.pyc
1313
_deps
14-
14+
*.orig

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
# Async - backend development framework in C++ using io_uring event-loop.
1+
# Helio - backend development framework in C++ using io_uring and epoll event-loop.
22

33
=====
44

55
[![ci-tests](https://github.com/romange/async/actions/workflows/ci.yml/badge.svg)](https://github.com/romange/async/actions/workflows/ci.yml)
66

7+
[![codecov](https://codecov.io/gh/romange/helio/graph/badge.svg?token=2TIU52DK17)](https://codecov.io/gh/romange/helio)
8+
79
Async is a set of c++ primitives that allows you efficient and rapid development
810
in c++17 on linux systems. The focus is mostly for backend development, data processing etc.
911

1012

1113
1. Dependency on [abseil-cpp](https://github.com/abseil/abseil-cpp/)
1214
2. Dependency on [Boost 1.71](https://www.boost.org/doc/libs/1_71_0/doc/html/)
1315
3. Uses ninja-build on top of cmake
14-
4. Build artifacts are docker-friendly.
16+
4. Built artifacts are docker-friendly.
1517
6. HTTP server implementation.
16-
7. Many other features.
18+
7. Fibers library and fiber-friendly synchronization primitives.
1719

1820

1921
I will gradually add explanations for most crucial blocks in this library.
@@ -22,7 +24,7 @@ I will gradually add explanations for most crucial blocks in this library.
2224
## Setting Up & Building
2325
```bash
2426
> sudo ./install-dependencies.sh
25-
> ./blaze.sh -ninja -release
27+
> ./blaze.sh -release
2628
> cd build-opt && ninja -j4 echo_server
2729

2830
```
@@ -37,6 +39,7 @@ I will gradually add explanations for most crucial blocks in this library.
3739

3840

3941
## HTTP
42+
4043
HTTP handler is implemented using [Boost.Beast](https://www.boost.org/doc/libs/1_71_0/libs/beast/doc/html/index.html) library. It's integrated with the io_uring based ProactorPool.
4144
Please see [http_main.cc](https://github.com/romange/async/blob/master/util/http/http_main.cc), for example. HTTP also provides support for backend monitoring (Varz status page) and for extensible debugging interface. With monitoring C++ backend returns json object that is formatted inside status page in the browser. To check how it looks, please go to [localhost:8080](http://localhost:8080) while `echo_server` is running.
4245

base/cxx_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class MyType {
7979

8080
template <typename T> class Wrapper {
8181
public:
82-
Wrapper(T s) : t(move(s)) {
82+
Wrapper(T s) : t(std::move(s)) {
8383
}
8484

8585
T t;
@@ -121,7 +121,7 @@ class Pointer1 {
121121

122122
TEST_F(CxxTest, Move) {
123123
MyType t{"foo"};
124-
MyType a = move(t);
124+
MyType a = std::move(t);
125125
EXPECT_EQ(0, copy_ctors);
126126

127127
vector<MyType> v;

cmake/third_party.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ endif()
230230

231231

232232
# 1.71 comes with ubuntu 20.04 so that's what we require.
233-
find_package(Boost 1.71.0 REQUIRED COMPONENTS context system fiber)
233+
find_package(Boost 1.71.0 REQUIRED COMPONENTS context system)
234234
Message(STATUS "Found Boost ${Boost_LIBRARY_DIRS} ${Boost_LIB_VERSION} ${Boost_VERSION}")
235235

236236
add_definitions(-DBOOST_BEAST_SEPARATE_COMPILATION -DBOOST_ASIO_SEPARATE_COMPILATION)

examples/echo_server.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct TL {
7272

7373
auto res = uring::OpenLinux(path, flags, 0666);
7474
CHECK(res);
75-
file = move(res.value());
75+
file = std::move(res.value());
7676
#if 0
7777
Proactor* proactor = (Proactor*)ProactorBase::me();
7878
uring::FiberCall fc(proactor);
@@ -107,7 +107,7 @@ void TL::WriteToFile() {
107107
++pending_write_reqs;
108108
uring::Proactor* proactor = (uring::Proactor*)ProactorBase::me();
109109

110-
uring::SubmitEntry se = proactor->GetSubmitEntry(move(ring_cb), 0);
110+
uring::SubmitEntry se = proactor->GetSubmitEntry(std::move(ring_cb), 0);
111111
se.PrepWrite(file->fd(), blob, 4096, 0);
112112
if (GetFlag(FLAGS_sqe_async))
113113
se.sqe()->flags |= IOSQE_ASYNC;
@@ -289,7 +289,7 @@ void RunServer(ProactorPool* pp) {
289289
LOG(ERROR) << "Error writing to file " << -res;
290290
};
291291

292-
uring::SubmitEntry se = proactor->GetSubmitEntry(move(ring_cb), 0);
292+
uring::SubmitEntry se = proactor->GetSubmitEntry(std::move(ring_cb), 0);
293293
se.PrepWrite(tl->file->fd(), blob, 4096, 0);
294294
se.sqe()->flags |= IOSQE_ASYNC;
295295
if (i % 1000 == 0) {

examples/pingserver/resp_parser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ auto RespParser::ConsumeBulk(Buffer str) -> Status {
311311
std::unique_ptr<uint8_t[]> nb(new uint8_t[bulk_len_]);
312312
memcpy(nb.get(), str.data(), len);
313313
bulk_str = Buffer{nb.get(), len};
314-
buf_stash_.emplace_back(move(nb));
314+
buf_stash_.emplace_back(std::move(nb));
315315
is_broken_token_ = true;
316316
}
317317
last_consumed_ = len;

examples/raw_echo_server.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void DispatchCqe(FiberInterface* current, const io_uring_cqe& cqe) {
290290
res.flags = cqe.flags;
291291
suspended_list[index].next = next_rp_id;
292292
next_rp_id = index;
293-
auto func = move(suspended_list[index].cb);
293+
auto func = std::move(suspended_list[index].cb);
294294
func(current, res);
295295
}
296296

io/proc_reader.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Result<StatusData> ReadStatusInfo() {
107107
}
108108
};
109109

110-
error_code ec = ReadProcFile("/proc/self/status", ':', move(cb));
110+
error_code ec = ReadProcFile("/proc/self/status", ':', std::move(cb));
111111
if (ec)
112112
return make_unexpected(ec);
113113

@@ -142,7 +142,7 @@ Result<MemInfoData> ReadMemInfo() {
142142
}
143143
};
144144

145-
error_code ec = ReadProcFile("/proc/meminfo", ':', move(cb));
145+
error_code ec = ReadProcFile("/proc/meminfo", ':', std::move(cb));
146146
if (ec)
147147
return make_unexpected(ec);
148148

@@ -161,7 +161,7 @@ Result<SelfStat> ReadSelfStat() {
161161
}
162162
};
163163

164-
error_code ec = ReadProcFile("/proc/stat", ' ', move(cb));
164+
error_code ec = ReadProcFile("/proc/stat", ' ', std::move(cb));
165165
if (ec)
166166
return make_unexpected(ec);
167167
}

util/cloud/s3.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ io::Result<io::WriteFile*> S3Bucket::OpenWriteFile(std::string_view path) {
297297
} else {
298298
full_path = absl::StrCat(bucket_, "/", path);
299299
}
300-
unique_ptr http_client = move(http_client_);
300+
unique_ptr http_client = std::move(http_client_);
301301
error_code ec = Connect(http_client->connect_timeout_ms());
302302
if (ec)
303303
return make_unexpected(ec);

0 commit comments

Comments
 (0)