mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-06-09 08:44:49 -04:00
I'm using the HYG star database v3 from: https://github.com/astronexus/HYG-Database I compare the star constellations it reports against what I calculate from the star RA/DEC it lists. When I try this against all stars in the database, I find 25 disagreements about which constellation contains the star. Another person found 3 disagreements. See: https://github.com/astronexus/HYG-Database/issues/21 For now, I'm testing only the stars brighter than mag 4.890, which eliminates all the disagreements, and still gets me over 1000 test cases. Also, now I'm verifying ephemeris file and star database checksums whether or not they have just been downloaded. The idea is to catch corruption or unexpected changes each time I run the unit test.
174 lines
5.4 KiB
Bash
Executable File
174 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
Fail()
|
|
{
|
|
echo "ERROR($0): $1"
|
|
exit 1
|
|
}
|
|
|
|
IsInstalled()
|
|
{
|
|
type "$1" > /dev/null 2>&1
|
|
return $?
|
|
}
|
|
|
|
OUTDIR=../source
|
|
EPHFILE=lnxp1600p2200.405
|
|
# EPHURL=ftp://ssd.jpl.nasa.gov/pub/eph/planets/Linux/de405/${EPHFILE}
|
|
EPHURL=https://github.com/cosinekitty/ephemeris/raw/master/${EPHFILE}
|
|
|
|
if [[ ! -f ${EPHFILE} ]]; then
|
|
echo ""
|
|
echo "Ephemeris file not found: ${EPHFILE}"
|
|
echo "Trying to download for you from:"
|
|
echo "${EPHURL}"
|
|
echo ""
|
|
if IsInstalled wget; then
|
|
wget_success=false
|
|
for attempt in {1..10}; do
|
|
if [[ ${attempt} > 1 ]]; then
|
|
echo "wget failed (attempt ${attempt} of 10) -- will retry download in 9 seconds..."
|
|
sleep 9
|
|
fi
|
|
if wget ${EPHURL}; then
|
|
echo "wget successfully downloaded the ephemeris file."
|
|
wget_success=true
|
|
break
|
|
fi
|
|
done
|
|
[[ ${wget_success} == true ]] || Fail "Could not download using wget: ${EPHFILE}"
|
|
elif IsInstalled curl; then
|
|
curl -L -o ${EPHFILE} ${EPHURL} || Fail "Could not download using curl: ${EPHFILE}"
|
|
else
|
|
echo "Neither wget nor curl is installed. Use your browser to download"
|
|
echo "the file at the URL above into this directory."
|
|
echo "Then run this script again to continue."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if IsInstalled sha256sum; then
|
|
if sha256sum -c ephemeris.sha256; then
|
|
echo "Validated ephemeris using sha256 checksum."
|
|
else
|
|
rm -f ${EPHFILE}
|
|
Fail "Detected corrupt ephemeris file: failed sha256 check."
|
|
fi
|
|
elif IsInstalled md5sum; then
|
|
if md5sum -c ephemeris.md5; then
|
|
echo "Validated ephemeris using md5 checksum."
|
|
else
|
|
rm -f ${EPHFILE}
|
|
Fail "Detected corrupt ephemeris file: failed md5 check."
|
|
fi
|
|
else
|
|
echo "Warning: could not validate ephemeris file with md5 or sha256."
|
|
fi
|
|
|
|
STARFILE=hygdata_v3.csv
|
|
STARURL=https://raw.githubusercontent.com/astronexus/HYG-Database/master/hygdata_v3.csv
|
|
STARMD5=hygdata_v3.md5
|
|
STARSHA=hygdata_v3.sha256
|
|
if [[ ! -f ${STARFILE} ]]; then
|
|
echo ""
|
|
echo "Star database not found: ${STARFILE}"
|
|
echo "Trying to download for you from:"
|
|
echo "${STARURL}"
|
|
echo ""
|
|
if IsInstalled wget; then
|
|
wget_success=false
|
|
for attempt in {1..10}; do
|
|
if [[ ${attempt} > 1 ]]; then
|
|
echo "wget failed (attempt ${attempt} of 10) -- will retry download in 9 seconds..."
|
|
sleep 9
|
|
fi
|
|
if wget ${STARURL}; then
|
|
echo "wget successfully downloaded the star database."
|
|
wget_success=true
|
|
break
|
|
fi
|
|
done
|
|
[[ ${wget_success} == true ]] || Fail "Could not download using wget: ${STARFILE}"
|
|
elif IsInstalled curl; then
|
|
curl -L -o ${STARFILE} ${STARURL} || Fail "Could not download using curl: ${STARFILE}"
|
|
else
|
|
echo "Neither wget nor curl is installed. Use your browser to download"
|
|
echo "the file at the URL above into this directory."
|
|
echo "Then run this script again to continue."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if IsInstalled sha256sum; then
|
|
if sha256sum -c ${STARSHA}; then
|
|
echo "Validated star database using sha256 checksum."
|
|
else
|
|
rm -f ${STARFILE}
|
|
Fail "Detected corrupt star database: failed sha256 check."
|
|
fi
|
|
elif IsInstalled md5sum; then
|
|
if md5sum -c ${STARMD5}; then
|
|
echo "Validated star database using md5 checksum."
|
|
else
|
|
rm -f ${STARFILE}
|
|
Fail "Detected corrupt star database: failed md5 check."
|
|
fi
|
|
else
|
|
echo "Warning: could not validate star database with md5 or sha256."
|
|
fi
|
|
|
|
rm -f constellation/test_input.txt
|
|
./make_constellation_data.py || Fail "Error creating constellation test data."
|
|
|
|
cd .. || Fail "Cannot change to parent directory."
|
|
python3 generate/update_copyrights.py $(git grep -l Copyright -- generate hydrogen LICENSE source/c/astronomy.h) ||
|
|
Fail "Error updating copyrights."
|
|
cd generate || Fail "Cannot change back to generate directory."
|
|
|
|
echo ""
|
|
echo "Building C source code for 'generate' program."
|
|
./build || Fail "Could not build 'generate' program from source."
|
|
|
|
mkdir -pv output temp apsides || Fail "Error creating directories."
|
|
rm -f temp/*
|
|
|
|
FASTMODE=true
|
|
for file in output/vsop_{0,1,3,4,5,6,7,11}.txt output/08.eph; do
|
|
if [[ ! -f ${file} ]]; then
|
|
echo "Missing required planet model file: ${file}"
|
|
FASTMODE=false
|
|
fi
|
|
done
|
|
|
|
if [[ "${FASTMODE}" == "false" ]]; then
|
|
echo ""
|
|
echo "Generating planet models."
|
|
rm -f output/vsop_*.txt output/*.eph
|
|
./generate planets || Fail "Could not generate planet models."
|
|
fi
|
|
|
|
echo ""
|
|
echo "Generating apsis test data."
|
|
rm -f apsides/apsis_*.txt
|
|
./generate apsis || Fail "Could not generate apsis test data."
|
|
|
|
./makedoc || exit $?
|
|
./unit_test_csharp || exit $?
|
|
./unit_test_js || exit $?
|
|
./unit_test_c || exit $?
|
|
./unit_test_python || exit $?
|
|
|
|
echo ""
|
|
echo "Testing example programs."
|
|
cd ../demo/c || Fail "Cannot change directory to ../demo/c"
|
|
test/test || Fail "Error testing C examples"
|
|
cd ../nodejs || Fail "Cannot change directory to ../nodejs"
|
|
test/test || Fail "Error testing nodejs examples."
|
|
cd ../python || Fail "Cannot change directory to ../python"
|
|
test/test || Fail "Error testing Python examples."
|
|
cd ../csharp || Fail "Cannot change directory to ../csharp"
|
|
test/test || Fail "Error testing C# examples."
|
|
cd ../../generate || Fail "Cannot change back to generate directory."
|
|
|
|
cat pass.txt
|
|
exit 0
|