Skip to content

Commit

Permalink
Merge branch 'validation-updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
gfiumara committed Oct 4, 2023
2 parents dd80cce + 81d2876 commit 340d291
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 43 deletions.
28 changes: 14 additions & 14 deletions elft_1_x/include/elft.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,17 @@ namespace ELFT
* @param bpp
* Number of bits comprising a single pixel (8, 16, 24, or 48).
* @param pixels
* #width * #height * (#bpp / #bpc) bytes of image data, with
* `pixels.front()` representing the first byte of the top-left
* pixel, and `pixels.back()` representing the last byte of
* bottom-right pixel. It is decompressed big endian image
* data, canonically coded as defined in ISO/IEC 19794-4:2005,
* section 6.2. For example, 0xFF00 is closer to white than it
* is to black.
* `width` * `height` * (`bpp` / `bpc`) bytes of image data,
* with `pixels.front()` representing the first byte of the
* top-left pixel, and `pixels.back()` representing the last
* byte of the bottom-right pixel. It is decompressed big endian
* image data, canonically coded as defined in
* ISO/IEC 19794-4:2005, section 6.2. For example, 0xFF00 is
* closer to white than it is to black.
*
* @note
* Number of color components is #bpp / #bpc and shall be either
* 1 (grayscale) or 3 (RGB).
* Number of color components is `bpp` / `bpc` and shall be
* either 1 (grayscale) or 3 (RGB).
*/
Image(
const uint8_t identifier,
Expand Down Expand Up @@ -284,7 +284,7 @@ namespace ELFT
* @details
* #width * #height * (#bpp / #bpc) bytes of image data, with
* `pixels.front()` representing the first byte of the top-left
* pixel, and `pixels.back()` representing the last byte of
* pixel, and `pixels.back()` representing the last byte of the
* bottom-right pixel. It is decompressed big endian image
* data, canonically coded as defined in ISO/IEC 19794-4:2005,
* section 6.2. For example, 0xFF00 is closer to white than it
Expand Down Expand Up @@ -1291,7 +1291,7 @@ namespace ELFT
* @brief
* Load reference database into memory.
*
* @param maxSize
* @param maxSize
* Suggested maximum number of bytes of memory to consume in
* support of searching the reference database faster.
*
Expand Down Expand Up @@ -1336,7 +1336,7 @@ namespace ELFT
* If the reference database is already loaded when this method
* is called, this method shall return immediately.
*
* @note
* @note
* This method need not be threadsafe. It may use more than one
* thread.
*
Expand Down Expand Up @@ -1473,10 +1473,10 @@ namespace ELFT
* Do **not** load your reference database into memory on
* construction. Instead, wait for a call to load().
* @warning
* It is possible that #databaseDirectory does not exist when
* It is possible that `databaseDirectory` does not exist when
* this function is called, but it will exist before load() is
* called. Do **not** emit errors based on the contents of
* #databaseDirectory from this function. This is necessary to
* `databaseDirectory` from this function. This is necessary to
* call getIdentification() prior to creating an enrollment
* database.
*
Expand Down
2 changes: 1 addition & 1 deletion elft_1_x/validation/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
202304051521
202310021440
39 changes: 38 additions & 1 deletion elft_1_x/validation/src/elft_validation_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,24 @@ namespace ELFT::Validation::Data
}
}}},

/*
* Nonsensical images
*/
{"solid_0_500x500-probe", {
{"solid_0_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"solid_128_500x500-probe", {
{"solid_128_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"solid_250_500x500-probe", {
{"solid_250_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"solid_255_500x500-probe", {
{"solid_255_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"fd249-probe", {
{"fd249_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"gradient-probe", {
{"gradient_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"random-probe", {
{"random_500x500.gray", 500, 500, 500, 8, 8, {}}}},

};

/** Images to be made into reference templates. */
Expand Down Expand Up @@ -5664,7 +5682,26 @@ namespace ELFT::Validation::Data
FrictionRidgeCaptureTechnology::OpticalTIRBright,
FrictionRidgeGeneralizedPosition::RightFour,
{}, {}, ValueAssessment::Value}}}
}
},

/*
* Nonsensical images
*/
{"solid_0_500x500-ref", {
{"solid_0_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"solid_128_500x500-ref", {
{"solid_128_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"solid_250_500x500-ref", {
{"solid_250_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"solid_255_500x500-ref", {
{"solid_255_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"fd249-ref", {
{"fd249_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"gradient-ref", {
{"gradient_500x500.gray", 500, 500, 500, 8, 8, {}}}},
{"random-ref", {
{"random_500x500.gray", 500, 500, 500, 8, 8, {}}}},

};
}

Expand Down
121 changes: 94 additions & 27 deletions elft_1_x/validation/validate
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ check_validation_version()
check_image_versions()
{
# Version of image dataset compatible with this script
local expected_image_version="202103120958"
local expected_image_version="202310021336"
echo -n "Checking validation image versions... "
Expand Down Expand Up @@ -1091,10 +1091,10 @@ compile()
declare -A md5s
md5s["../libelft/libelft.cpp"]="b7105274543b422e51c656d8db36b165"
md5s["../include/elft.h"]="fc66e34adc54b5b2fc78f62d1ea4191e"
md5s["../include/elft.h"]="ce24b0938194e063719c3c8f10828005"
md5s["src/elft_validation.cpp"]="973915d876b71e77afba122cf5d492bd"
md5s["src/elft_validation.h"]="c27629ef53a2f86874fe7b89de301d49"
md5s["src/elft_validation_data.h"]="e2d931dc343a149f0f6ab409b83f611f"
md5s["src/elft_validation_data.h"]="6ed6a603ceb0f0b206c13b207265d353"
md5s["src/elft_validation_utils.h"]="1608f980123e57619d92370feddf9225"
# Check checksums
Expand Down Expand Up @@ -1146,6 +1146,19 @@ compile()
fail "${msg}"
fi
# Suspected non libraries in library directory
local non_libs
non_libs="$(find "${local_lib_dir}" \! -name "lib*" -a \! \
-name README | wc -l)"
if [ "${non_libs}" -gt 0 ]; then
local msg="You have files in ${local_lib_dir} that don't "
msg+="appear to be libraries. That's fine, but are you sure "
msg+="they don't belong in \"${local_config_dir}\" instead?"
warn "${msg}"
echo -n "Still building... "
fi
# Catch the case of hardcoding "../lib", etc. into library by always
# linking against libs in a different directory
local tmp_dir
Expand Down Expand Up @@ -1232,15 +1245,42 @@ compile()
local num_libs
num_libs="$(find "${lib_dir}" -name "lib*" -type f | wc -l)"
if [ "${num_libs}" -gt 2 ]; then
if ! readelf -d "${lib_dir}/${core_lib}" | \
grep RUNPATH | grep "\$ORIGIN" > /dev/null
# RUNPATH preferred over RPATH
local uses_rpath=0
if readelf -d "${lib_dir}/${core_lib}" | grep -q RPATH; then
uses_rpath=1
fi
if [ "${uses_rpath}" == "1" ]; then
local msg="You are setting RPATH, but RUNPATH is "
msg+="preferred for new development. Please consider "
msg+="setting RUNPATH instead of RPATH."
warn "${msg}"
echo -n "Still building... "
fi
# Check for $ORIGIN in both RPATH and RUNPATH
local origin_in_rpath=0
if [ "${uses_rpath}" == "1" ]; then
if readelf -d "${lib_dir}/${core_lib}" | \
grep RPATH | grep "\$ORIGIN" > /dev/null; then
origin_in_rpath=1
fi
fi
local origin_in_runpath=0
if readelf -d "${lib_dir}/${core_lib}" | \
grep RUNPATH | grep "\$ORIGIN" > /dev/null; then
origin_in_runpath=1
fi
if [ "${origin_in_rpath}" == "0" ] && \
[ "${origin_in_runpath}" == "0" ]
then
local msg="You have supplied multiple libraries, but "
msg+="${core_lib} does not have an RUNPATH of \$ORIGIN."
msg+=" This may cause runtime issues, because the "
msg+="${core_lib} does not have a RUNPATH of \$ORIGIN. "
msg+="This may cause runtime issues, because the "
msg+="location of libraries on NIST's systems will not "
msg+="be laid out the same as in this validation "
msg+="package and the only library explicitly linked "
msg+="package, and the only library explicitly linked "
msg+="will be ${core_lib}."
warn "${msg}"
Expand All @@ -1260,19 +1300,6 @@ compile()
fi
done < <(find "${lib_dir}" -type f -name "lib*")
# Suspected non libraries in library directory
local non_libs
non_libs="$(find "${local_lib_dir}" \! -name "lib*" -a \! \
-name README | wc -l)"
if [ "${non_libs}" -gt 0 ]; then
local msg="You have files in ${local_lib_dir} that don't "
msg+="appear to be libraries. That's fine, but are you sure "
msg+="they don't belong in \"${local_config_dir}\" instead?"
warn "${msg}"
echo -n "Still building... "
fi
# Log some extra compilation information that may be useful in helping
# to debug future issues
{
Expand Down Expand Up @@ -1369,7 +1396,7 @@ clean_previous_attempts()
find /tmp -maxdepth 1 -type d -name 'elft_libs.*' -exec rm -rf {} \;
find /tmp -maxdepth 1 -type d -name 'elft_configs.*' \
-exec chmod +w {} \;
-exec chmod -R +w {} \;
find /tmp -maxdepth 1 -type d -name 'elft_configs.*' -exec rm -rf {} \;
find /tmp -maxdepth 1 -type d -name 'elft_validation_build.*' \
-exec rm -rf {} \;
Expand Down Expand Up @@ -1741,6 +1768,21 @@ check_search_candidates()
local too_many=0
local neg_sim=0
local candidate_log="${driver_output_dir}/searchCandidates.log"
if ! check_counts "$(basename "${candidate_log}" .log)"; then
local msg="Incorrect number of lines in search log. Please "
msg+="review: "
fail "${msg}" "$(rp "${candidate_log}")"
fi
local num_probes=0
num_probes=$(cut -f 1 -d ',' "${candidate_log}" | sort | uniq | wc -l)
if [ "${num_probes}" -ne "125" ]; then
local msg="Incorrect number of probes in search log. Please "
msg+="review: "
fail "${msg}" "$(rp "${candidate_log}")"
fi
while read -r line; do
read -r max_candidates result num_candidates rank \
similarity <<< "$(cut -f 2,4,7,8,11 -d ',' \
Expand Down Expand Up @@ -1813,14 +1855,23 @@ check_counts()
local log_key="${1}"
declare -A counts
counts["extractionCreate-0"]=117
counts["extractionCreate-1"]=55
declare -A comparators
counts["extractionCreate-0"]=124
comparators["extractionCreate-0"]="eq"
counts["extractionCreate-1"]=62
comparators["extractionCreate-1"]="eq"
counts["searchCandidates"]=124
comparators["searchCandidates"]="ge"
# Not all logs have an expected number of lines
local expected="${counts["${log_key}"]}"
if [ "${expected}" == "" ]; then
return 0
fi
local comparator="${comparators["${log_key}"]}"
if [ "${comparator}" == "" ]; then
fail "NIST error in check_counts"
fi
local actual
if ! actual="$(num_lines_in_file "${log}")"; then
Expand All @@ -1829,10 +1880,26 @@ check_counts()
# Remove header
actual=$(( actual - 1 ))
if [ "${expected}" -eq "${actual}" ]; then
return 0
if [ "${comparator}" == "eq" ]; then
if [ "${actual}" -eq "${expected}" ]; then
return 0
else
return 1
fi
elif [ "${comparator}" == "ge" ]; then
if [ "${actual}" -ge "${expected}" ]; then
return 0
else
return 1
fi
elif [ "${comparator}" == "le" ]; then
if [ "${actual}" -le "${expected}" ]; then
return 0
else
return 1
fi
else
return 1
fail "NIST error in check_counts"
fi
}
Expand Down

0 comments on commit 340d291

Please sign in to comment.