Skip to content

Commit 1049491

Browse files
authored
Adding test runs to Azure Pipelines. (#899)
* Adding test runs to Pipelines. * Use get instead of then/wait in compression tests. * Fix typo to not write to *done. * Use dylib on MacOS.
1 parent c6377e9 commit 1049491

File tree

2 files changed

+46
-58
lines changed

2 files changed

+46
-58
lines changed

Release/tests/functional/http/client/compression_tests.cpp

Lines changed: 30 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ SUITE(compression_tests)
6262
if (_done)
6363
{
6464
input_bytes_processed = 0;
65-
if (*done)
65+
if (done)
6666
{
6767
*done = true;
6868
}
@@ -127,7 +127,7 @@ SUITE(compression_tests)
127127
if (_done)
128128
{
129129
input_bytes_processed = 0;
130-
if (*done)
130+
if (done)
131131
{
132132
*done = true;
133133
}
@@ -203,7 +203,6 @@ SUITE(compression_tests)
203203
std::vector<uint8_t> dcmp_buffer;
204204
web::http::compression::operation_result r;
205205
std::vector<size_t> chunk_sizes;
206-
pplx::task_status result;
207206
size_t csize;
208207
size_t dsize;
209208
size_t i;
@@ -240,15 +239,11 @@ SUITE(compression_tests)
240239
cmp_buffer.resize(buffer_size); // pessimistic (or not, for non-compressible data)
241240
for (i = 0; i < buffer_size; i += chunk_size)
242241
{
243-
result = compressor
244-
->compress(input_buffer.data() + i,
245-
std::min(chunk_size, buffer_size - i),
246-
cmp_buffer.data() + csize,
247-
std::min(chunk_size, buffer_size - csize),
248-
web::http::compression::operation_hint::has_more)
249-
.then([&r](web::http::compression::operation_result x) { r = x; })
250-
.wait();
251-
VERIFY_ARE_EQUAL(result, pplx::task_status::completed);
242+
r = compressor->compress(input_buffer.data() + i,
243+
std::min(chunk_size, buffer_size - i),
244+
cmp_buffer.data() + csize,
245+
std::min(chunk_size, buffer_size - csize),
246+
web::http::compression::operation_hint::has_more).get();
252247
VERIFY_ARE_EQUAL(r.input_bytes_processed, std::min(chunk_size, buffer_size - i));
253248
VERIFY_ARE_EQUAL(r.done, false);
254249
chunk_sizes.push_back(r.output_bytes_produced);
@@ -265,30 +260,24 @@ SUITE(compression_tests)
265260
cmpsize += std::min(chunk_size, (size_t)200);
266261
cmp_buffer.resize(cmpsize);
267262
}
268-
result = compressor
269-
->compress(NULL,
263+
r = compressor->compress(NULL,
270264
0,
271265
cmp_buffer.data() + csize,
272266
std::min(chunk_size, cmpsize - csize),
273-
web::http::compression::operation_hint::is_last)
274-
.then([&r](web::http::compression::operation_result x) { r = x; })
275-
.wait();
276-
VERIFY_ARE_EQUAL(result, pplx::task_status::completed);
267+
web::http::compression::operation_hint::is_last).get();
277268
VERIFY_ARE_EQUAL(r.input_bytes_processed, 0);
278269
chunk_sizes.push_back(r.output_bytes_produced);
279270
csize += r.output_bytes_produced;
280271
} while (csize == cmpsize);
281272
VERIFY_ARE_EQUAL(r.done, true);
282273

283274
// once more with no input, to assure no error and done
284-
result = compressor->compress(NULL, 0, NULL, 0, web::http::compression::operation_hint::is_last)
285-
.then([&r](web::http::compression::operation_result x) { r = x; })
286-
.wait();
287-
VERIFY_ARE_EQUAL(result, pplx::task_status::completed);
275+
r = compressor->compress(NULL, 0, NULL, 0, web::http::compression::operation_hint::is_last).get();
288276
VERIFY_ARE_EQUAL(r.input_bytes_processed, 0);
289277
VERIFY_ARE_EQUAL(r.output_bytes_produced, 0);
290278
VERIFY_ARE_EQUAL(r.done, true);
291279
}
280+
292281
cmp_buffer.resize(csize); // actual
293282

294283
// decompress in as-compressed chunks
@@ -304,15 +293,12 @@ SUITE(compression_tests)
304293
{
305294
hint = web::http::compression::operation_hint::is_last;
306295
}
307-
result = decompressor
308-
->decompress(cmp_buffer.data() + nn,
309-
*it,
310-
dcmp_buffer.data() + dsize,
311-
std::min(chunk_size, buffer_size - dsize),
312-
hint)
313-
.then([&r](web::http::compression::operation_result x) { r = x; })
314-
.wait();
315-
VERIFY_ARE_EQUAL(result, pplx::task_status::completed);
296+
297+
r = decompressor->decompress(cmp_buffer.data() + nn,
298+
*it,
299+
dcmp_buffer.data() + dsize,
300+
std::min(chunk_size, buffer_size - dsize),
301+
hint).get();
316302
nn += *it;
317303
dsize += r.output_bytes_produced;
318304
}
@@ -332,15 +318,11 @@ SUITE(compression_tests)
332318
size_t n = std::min(chunk_size, csize - nn);
333319
do
334320
{
335-
result = decompressor
336-
->decompress(cmp_buffer.data() + nn,
337-
n,
338-
dcmp_buffer.data() + dsize,
339-
std::min(chunk_size, buffer_size - dsize),
340-
web::http::compression::operation_hint::has_more)
341-
.then([&r](web::http::compression::operation_result x) { r = x; })
342-
.wait();
343-
VERIFY_ARE_EQUAL(result, pplx::task_status::completed);
321+
r = decompressor->decompress(cmp_buffer.data() + nn,
322+
n,
323+
dcmp_buffer.data() + dsize,
324+
std::min(chunk_size, buffer_size - dsize),
325+
web::http::compression::operation_hint::has_more).get();
344326
dsize += r.output_bytes_produced;
345327
nn += r.input_bytes_processed;
346328
n -= r.input_bytes_processed;
@@ -352,26 +334,19 @@ SUITE(compression_tests)
352334
VERIFY_IS_TRUE(r.done);
353335

354336
// once more with no input, to assure no error and done
355-
result = decompressor->decompress(NULL, 0, NULL, 0, web::http::compression::operation_hint::has_more)
356-
.then([&r](web::http::compression::operation_result x) { r = x; })
357-
.wait();
358-
VERIFY_ARE_EQUAL(result, pplx::task_status::completed);
337+
r = decompressor->decompress(NULL, 0, NULL, 0, web::http::compression::operation_hint::has_more).get();
359338
VERIFY_ARE_EQUAL(r.input_bytes_processed, 0);
360339
VERIFY_ARE_EQUAL(r.output_bytes_produced, 0);
361340
VERIFY_IS_TRUE(r.done);
362341

363342
// decompress all at once
364343
decompressor->reset();
365344
memset(dcmp_buffer.data(), 0, dcmp_buffer.size());
366-
result = decompressor
367-
->decompress(cmp_buffer.data(),
368-
csize,
369-
dcmp_buffer.data(),
370-
dcmp_buffer.size(),
371-
web::http::compression::operation_hint::is_last)
372-
.then([&r](web::http::compression::operation_result x) { r = x; })
373-
.wait();
374-
VERIFY_ARE_EQUAL(result, pplx::task_status::completed);
345+
r = decompressor->decompress(cmp_buffer.data(),
346+
csize,
347+
dcmp_buffer.data(),
348+
dcmp_buffer.size(),
349+
web::http::compression::operation_hint::is_last).get();
375350
VERIFY_ARE_EQUAL(r.output_bytes_produced, buffer_size);
376351
VERIFY_ARE_EQUAL(input_buffer, dcmp_buffer);
377352

@@ -385,14 +360,11 @@ SUITE(compression_tests)
385360
nn = 0;
386361
try
387362
{
388-
result = decompressor
389-
->decompress(cmp_buffer.data(),
363+
r = decompressor->decompress(cmp_buffer.data(),
390364
csize,
391365
dcmp_buffer.data(),
392366
dcmp_buffer.size(),
393-
web::http::compression::operation_hint::is_last)
394-
.then([&nn](web::http::compression::operation_result x) { nn++; })
395-
.wait();
367+
web::http::compression::operation_hint::is_last).get();
396368
nn++;
397369
}
398370
catch (std::runtime_error)

azure-pipelines.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
cd build.debug
2121
ninja -j 4
2222
displayName: 'Run ninja'
23+
- script: |
24+
cd build.debug/Release/Binaries
25+
./test_runner *test.so
26+
displayName: 'Run Tests'
2327
- job: Ubuntu_1604_Apt_Release
2428
pool:
2529
vmImage: 'Ubuntu 16.04'
@@ -39,6 +43,10 @@ jobs:
3943
cd build.release
4044
ninja -j 4
4145
displayName: 'Run ninja'
46+
- script: |
47+
cd build.release/Release/Binaries
48+
./test_runner *test.so
49+
displayName: 'Run Tests'
4250
- job: MacOS_Debug
4351
pool:
4452
vmImage: 'macOS-10.13'
@@ -55,6 +63,10 @@ jobs:
5563
cd build.debug
5664
ninja -j 4
5765
displayName: 'Run ninja'
66+
- script: |
67+
cd build.debug/Release/Binaries
68+
./test_runner *test.dylib
69+
displayName: 'Run Tests'
5870
- job: MacOS_Release
5971
pool:
6072
vmImage: 'macOS-10.13'
@@ -71,3 +83,7 @@ jobs:
7183
cd build.release
7284
ninja -j 4
7385
displayName: 'Run ninja'
86+
- script: |
87+
cd build.release/Release/Binaries
88+
./test_runner *test.dylib
89+
displayName: 'Run Tests'

0 commit comments

Comments
 (0)