Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Created tests for hardware functions.
Created tests for all API functions exported in src/liblzma/api/lzma/hardware.h. The tests are fairly trivial but are helpful because they will inform users if their machines cannot support these functions. They also improve the code coverage metrics.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// | ||
/// \file test_hardware.c | ||
/// \brief Tests src/liblzma/api/lzma/hardware.h API functions | ||
/// | ||
/// Since the output values of these functions are hardware dependent, these | ||
/// tests are trivial. They are simply used to detect errors and machines | ||
/// that these function are not supported on. | ||
// | ||
// Author: Jia Tan | ||
// | ||
// This file has been put into the public domain. | ||
// You can do whatever you want with this file. | ||
// | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "tests.h" | ||
|
||
|
||
static void | ||
test_lzma_physmem(void) | ||
{ | ||
// NOTE: Use _skip instead of _fail because 0 can also mean that we | ||
// don't know how to get this information on this operating system. | ||
if (lzma_physmem() == 0) | ||
assert_skip("Could not determine amount of physical memory"); | ||
} | ||
|
||
|
||
static void | ||
test_lzma_cputhreads(void) | ||
{ | ||
if (lzma_cputhreads() == 0) | ||
assert_skip("Could not determine cpu core count"); | ||
} | ||
|
||
|
||
extern int | ||
main(int argc, char **argv) | ||
{ | ||
tuktest_start(argc, argv); | ||
tuktest_run(test_lzma_physmem); | ||
tuktest_run(test_lzma_cputhreads); | ||
return tuktest_end(); | ||
} |
aa75c55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The beginning of the backdoor man.
aa75c55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZTlzaXJxZjA1dmYyZ3EyaDhsdnd0aDAyNHluZ2w5NGd6eXI3OGszZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Y4hKMjN3z9fmhDCz2s/giphy.mp4