-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add a fuzz target for measurement, and remove the fuzz target for string with flags since that didn't seem to do much. * update circle ci to create artifacts for the measurement test * update the fuzzing target and quick fuzz target and the is_valid for measurements to trap error and invalid units * add a check for parenthesis after a leading multiplier * try trapping root powers of 2 and negative numbers * try using normalcy as a check in the measurement fuzzer * add another fuzz failure, try manipulating the tests a little to not have some odd conditions * make a fix to handle cases like cindex} which somehow registers as valid unit when it shouldn't * add a few more things to the dictionary * add some measurement tests for negative values in roots and string outputs. * update dockerfile and fuzz_script.sh to use the measurement for a while
- Loading branch information
Showing
22 changed files
with
191 additions
and
84 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
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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
/* | ||
Copyright (c) 2019-2020, | ||
Lawrence Livermore National Security, LLC; | ||
See the top-level NOTICE for additional details. All rights reserved. | ||
SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include "units/units.hpp" | ||
#include <cstring> | ||
#include <exception> | ||
#include <string> | ||
|
||
static bool cflag = units::disableCustomCommodities(); | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) | ||
{ | ||
if (Size == 0) { | ||
return 0; | ||
} | ||
std::string test1(reinterpret_cast<const char*>(Data), Size); | ||
|
||
auto meas1 = units::measurement_from_string(test1); | ||
if (isnormal(meas1)) { | ||
auto str = to_string(meas1); | ||
auto meas2 = units::measurement_from_string(str); | ||
if (!meas2.units().has_same_base(meas1.units()) && !isnormal(meas2)) { | ||
throw(6u); | ||
} | ||
bool match = (meas1 == meas2); | ||
if (!match) { | ||
auto mc1 = units::measurement_cast(meas1); | ||
auto mc2 = units::measurement_cast(meas2); | ||
match = (mc1 == mc2); | ||
|
||
if (!match && isnormal(root(meas2, 2))) { | ||
match = (root(mc2, 2) == root(mc1, 2)); | ||
} | ||
if (!match && isnormal(root(meas2, 3))) { | ||
match = (root(mc2, 3) == root(mc1, 3)); | ||
} | ||
} | ||
if (!match) { | ||
if (meas1.units() == meas2.units()) { | ||
throw(std::invalid_argument("measurement and conversion don't match but units do")); | ||
} | ||
throw(std::invalid_argument( | ||
"measurement and conversion don't match, units do not match")); | ||
} | ||
} | ||
// its::clearCustomCommodities(); | ||
return 0; // Non-zero return values are reserved for future use. | ||
} |
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 @@ | ||
*r' |
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 @@ | ||
���' |
Binary file not shown.
Binary file not shown.
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 @@ | ||
-2)0 |
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 @@ | ||
cindex}� |
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 @@ | ||
-�� |
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 @@ | ||
/�]/�/�/� |
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
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
Oops, something went wrong.