@@ -48,33 +48,33 @@ constexpr size_t msg_kickoff_size = sizeof(msg_kickoff) - 1;
48
48
49
49
// Private utils
50
50
51
- #define EMIT_WARNING (statements ) \
52
- do { \
53
- if (impl->settings .verbosity >= verbosity::warning ) { \
54
- std::stringstream ss; \
55
- ss << statements; \
56
- on_warning (ss.str ()); \
57
- } \
51
+ #define EMIT_WARNING (statements ) \
52
+ do { \
53
+ if (impl->settings .verbosity >= verbosity_warning ) { \
54
+ std::stringstream ss; \
55
+ ss << statements; \
56
+ on_warning (ss.str ()); \
57
+ } \
58
58
} while (0 )
59
59
60
- #define EMIT_INFO (statements ) \
60
+ #define EMIT_INFO (statements ) \
61
+ do { \
62
+ if (impl->settings .verbosity >= verbosity_info) { \
63
+ std::stringstream ss; \
64
+ ss << statements; \
65
+ on_info (ss.str ()); \
66
+ } \
67
+ } while (0 )
68
+
69
+ #define EMIT_DEBUG (statements ) \
61
70
do { \
62
- if (impl->settings .verbosity >= verbosity::info ) { \
71
+ if (impl->settings .verbosity >= verbosity_debug ) { \
63
72
std::stringstream ss; \
64
73
ss << statements; \
65
- on_info (ss.str ()); \
74
+ on_debug (ss.str ()); \
66
75
} \
67
76
} while (0 )
68
77
69
- #define EMIT_DEBUG (statements ) \
70
- do { \
71
- if (impl->settings .verbosity >= verbosity::debug) { \
72
- std::stringstream ss; \
73
- ss << statements; \
74
- on_debug (ss.str ()); \
75
- } \
76
- } while (0 )
77
-
78
78
#ifdef _WIN32
79
79
#define OS_ERROR_IS_EINTR () (false )
80
80
#define OS_SHUT_RDWR SD_BOTH
@@ -109,7 +109,7 @@ static void random_printable_fill(char *buffer, size_t length) noexcept {
109
109
}
110
110
}
111
111
112
- static double compute_speed (uint64_t data, double elapsed) noexcept {
112
+ static double compute_speed (double data, double elapsed) noexcept {
113
113
return (elapsed > 0.0 ) ? ((data * 8.0 ) / 1000.0 / elapsed) : 0.0 ;
114
114
}
115
115
@@ -247,21 +247,19 @@ bool Client::run() noexcept {
247
247
return true ;
248
248
}
249
249
250
- void Client::on_warning (const std::string &msg) noexcept {
250
+ void Client::on_warning (const std::string &msg) {
251
251
std::clog << " [!] " << msg << std::endl;
252
252
}
253
253
254
- void Client::on_info (const std::string &msg) noexcept {
255
- std::clog << msg << std::endl;
256
- }
254
+ void Client::on_info (const std::string &msg) { std::clog << msg << std::endl; }
257
255
258
- void Client::on_debug (const std::string &msg) noexcept {
256
+ void Client::on_debug (const std::string &msg) {
259
257
std::clog << " [D] " << msg << std::endl;
260
258
}
261
259
262
- void Client::on_performance (uint8_t tid, uint8_t nflows,
263
- uint64_t measured_bytes , double measured_interval ,
264
- double elapsed_time, double max_runtime) noexcept {
260
+ void Client::on_performance (uint8_t tid, uint8_t nflows, double measured_bytes,
261
+ double measured_interval , double elapsed_time ,
262
+ double max_runtime) {
265
263
auto speed = compute_speed (measured_bytes, measured_interval);
266
264
EMIT_INFO (" [" << std::fixed << std::setprecision (0 ) << std::setw (2 )
267
265
<< std::right << (elapsed_time * 100.0 / max_runtime) << " %]"
@@ -272,12 +270,11 @@ void Client::on_performance(uint8_t tid, uint8_t nflows,
272
270
<< std::right << speed << " kbit/s" );
273
271
}
274
272
275
- void Client::on_result (std::string scope, std::string name,
276
- std::string value) noexcept {
273
+ void Client::on_result (std::string scope, std::string name, std::string value) {
277
274
EMIT_INFO (" - [" << scope << " ] " << name << " : " << value);
278
275
}
279
276
280
- void Client::on_server_busy (std::string msg) noexcept {
277
+ void Client::on_server_busy (std::string msg) {
281
278
EMIT_WARNING (" server is busy: " << msg);
282
279
}
283
280
@@ -383,20 +380,20 @@ bool Client::recv_tests_ids() noexcept {
383
380
bool Client::run_tests () noexcept {
384
381
for (auto &tid : impl->granted_suite ) {
385
382
switch (tid) {
386
- case nettest_flag::upload :
383
+ case nettest_flag_upload :
387
384
EMIT_INFO (" running upload test" );
388
385
if (!run_upload ()) {
389
386
return false ;
390
387
}
391
388
break ;
392
- case nettest_flag::meta :
389
+ case nettest_flag_meta :
393
390
EMIT_DEBUG (" running meta test" ); // don't annoy the user with this
394
391
if (!run_meta ()) {
395
392
return false ;
396
393
}
397
394
break ;
398
- case nettest_flag::download :
399
- case nettest_flag::download_ext :
395
+ case nettest_flag_download :
396
+ case nettest_flag_download_ext :
400
397
EMIT_INFO (" running download test" );
401
398
if (!run_download ()) {
402
399
return false ;
@@ -543,7 +540,8 @@ bool Client::run_download() noexcept {
543
540
std::chrono::duration<double > measurement_interval = now - prev;
544
541
std::chrono::duration<double > elapsed = now - begin;
545
542
if (measurement_interval.count () > 0.25 ) {
546
- on_performance (nettest_flag::download, nflows, recent_data,
543
+ on_performance (nettest_flag_download, nflows,
544
+ static_cast <double >(recent_data),
547
545
measurement_interval.count (), elapsed.count (),
548
546
impl->settings .max_runtime );
549
547
recent_data = 0 ;
@@ -559,7 +557,8 @@ bool Client::run_download() noexcept {
559
557
}
560
558
auto now = std::chrono::steady_clock::now ();
561
559
std::chrono::duration<double > elapsed = now - begin;
562
- client_side_speed = compute_speed (total_data, elapsed.count ());
560
+ client_side_speed = compute_speed ( //
561
+ static_cast <double >(total_data), elapsed.count ());
563
562
}
564
563
565
564
{
@@ -711,7 +710,8 @@ bool Client::run_upload() noexcept {
711
710
std::chrono::duration<double > measurement_interval = now - prev;
712
711
std::chrono::duration<double > elapsed = now - begin;
713
712
if (measurement_interval.count () > 0.25 ) {
714
- on_performance (nettest_flag::upload, nflows, recent_data,
713
+ on_performance (nettest_flag_upload, nflows,
714
+ static_cast <double >(recent_data),
715
715
measurement_interval.count (), elapsed.count (),
716
716
impl->settings .max_runtime );
717
717
recent_data = 0 ;
@@ -727,7 +727,8 @@ bool Client::run_upload() noexcept {
727
727
}
728
728
auto now = std::chrono::steady_clock::now ();
729
729
std::chrono::duration<double > elapsed = now - begin;
730
- client_side_speed = compute_speed (total_data, elapsed.count ());
730
+ client_side_speed = compute_speed ( //
731
+ static_cast <double >(total_data), elapsed.count ());
731
732
EMIT_DEBUG (" run_upload: client computed speed: " << client_side_speed);
732
733
}
733
734
@@ -753,23 +754,22 @@ bool Client::msg_write_login(const std::string &version) noexcept {
753
754
static_assert (sizeof (impl->settings .nettest_flags ) == 1 ,
754
755
" nettest_flags too large" );
755
756
uint8_t code = 0 ;
756
- impl->settings .nettest_flags |= nettest_flag::status | nettest_flag::meta ;
757
- if ((impl->settings .nettest_flags & nettest_flag::middlebox )) {
758
- EMIT_WARNING (" msg_write_login(): nettest_flag::middlebox : not implemented" );
759
- impl->settings .nettest_flags &= ~nettest_flag::middlebox ;
757
+ impl->settings .nettest_flags |= nettest_flag_status | nettest_flag_meta ;
758
+ if ((impl->settings .nettest_flags & nettest_flag_middlebox )) {
759
+ EMIT_WARNING (" msg_write_login(): nettest_flag_middlebox : not implemented" );
760
+ impl->settings .nettest_flags &= ~nettest_flag_middlebox ;
760
761
}
761
- if ((impl->settings .nettest_flags & nettest_flag::simple_firewall )) {
762
+ if ((impl->settings .nettest_flags & nettest_flag_simple_firewall )) {
762
763
EMIT_WARNING (
763
- " msg_write_login(): nettest_flag::simple_firewall : not implemented" );
764
- impl->settings .nettest_flags &= ~nettest_flag::simple_firewall ;
764
+ " msg_write_login(): nettest_flag_simple_firewall : not implemented" );
765
+ impl->settings .nettest_flags &= ~nettest_flag_simple_firewall ;
765
766
}
766
- if ((impl->settings .nettest_flags & nettest_flag::upload_ext)) {
767
- EMIT_WARNING (
768
- " msg_write_login(): nettest_flag::upload_ext: not implemented" );
769
- impl->settings .nettest_flags &= ~nettest_flag::upload_ext;
767
+ if ((impl->settings .nettest_flags & nettest_flag_upload_ext)) {
768
+ EMIT_WARNING (" msg_write_login(): nettest_flag_upload_ext: not implemented" );
769
+ impl->settings .nettest_flags &= ~nettest_flag_upload_ext;
770
770
}
771
771
std::string serio;
772
- if ((impl->settings .protocol_flags & protocol_flag::json ) == 0 ) {
772
+ if ((impl->settings .protocol_flags & protocol_flag_json ) == 0 ) {
773
773
serio = std::string{(char *)&impl->settings .nettest_flags ,
774
774
sizeof (impl->settings .nettest_flags )};
775
775
code = msg_login;
@@ -787,7 +787,7 @@ bool Client::msg_write_login(const std::string &version) noexcept {
787
787
}
788
788
}
789
789
assert (code != 0 );
790
- if ((impl->settings .protocol_flags & protocol_flag::websockets ) != 0 ) {
790
+ if ((impl->settings .protocol_flags & protocol_flag_websockets ) != 0 ) {
791
791
EMIT_WARNING (" msg_write_login: websockets not supported" );
792
792
return false ;
793
793
}
@@ -802,7 +802,7 @@ bool Client::msg_write_login(const std::string &version) noexcept {
802
802
// a different implementation depending on the actual protocol.
803
803
bool Client::msg_write (uint8_t code, std::string &&msg) noexcept {
804
804
EMIT_DEBUG (" msg_write: message to send: " << represent (msg));
805
- if ((impl->settings .protocol_flags & protocol_flag::json ) != 0 ) {
805
+ if ((impl->settings .protocol_flags & protocol_flag_json ) != 0 ) {
806
806
nlohmann::json json;
807
807
json[" msg" ] = msg;
808
808
try {
@@ -812,7 +812,7 @@ bool Client::msg_write(uint8_t code, std::string &&msg) noexcept {
812
812
return false ;
813
813
}
814
814
}
815
- if ((impl->settings .protocol_flags & protocol_flag::websockets ) != 0 ) {
815
+ if ((impl->settings .protocol_flags & protocol_flag_websockets ) != 0 ) {
816
816
EMIT_WARNING (" msg_write: websockets not supported" );
817
817
return false ;
818
818
}
@@ -946,14 +946,14 @@ bool Client::msg_expect(uint8_t expected_code, std::string *s) noexcept {
946
946
bool Client::msg_read (uint8_t *code, std::string *msg) noexcept {
947
947
assert (code != nullptr && msg != nullptr );
948
948
std::string s;
949
- if ((impl->settings .protocol_flags & protocol_flag::websockets ) != 0 ) {
949
+ if ((impl->settings .protocol_flags & protocol_flag_websockets ) != 0 ) {
950
950
EMIT_WARNING (" msg_read: websockets not supported" );
951
951
return false ;
952
952
}
953
953
if (!msg_read_legacy (code, &s)) {
954
954
return false ;
955
955
}
956
- if ((impl->settings .protocol_flags & protocol_flag::json ) == 0 ) {
956
+ if ((impl->settings .protocol_flags & protocol_flag_json ) == 0 ) {
957
957
std::swap (s, *msg);
958
958
} else {
959
959
nlohmann::json json;
@@ -1516,7 +1516,7 @@ Err Client::netx_select(int numfd, fd_set *readset, fd_set *writeset,
1516
1516
1517
1517
// Dependencies (curl)
1518
1518
1519
- uint64_t Client::get_verbosity () const noexcept {
1519
+ uint32_t Client::get_verbosity () const noexcept {
1520
1520
return impl->settings .verbosity ;
1521
1521
}
1522
1522
0 commit comments