diff --git a/tests/data/MOD05_L2.A2019336.0000.061.2019336211522.hdf b/tests/data/MOD05_L2.A2019336.0000.061.2019336211522.hdf deleted file mode 100644 index fad54ad..0000000 Binary files a/tests/data/MOD05_L2.A2019336.0000.061.2019336211522.hdf and /dev/null differ diff --git a/tests/data/sids.py b/tests/data/srange_data.py similarity index 100% rename from tests/data/sids.py rename to tests/data/srange_data.py diff --git a/tests/test_intersect_single_res.py b/tests/test_intersect_single_res.py index 54209ad..c3e35ee 100644 --- a/tests/test_intersect_single_res.py +++ b/tests/test_intersect_single_res.py @@ -1,5 +1,3 @@ -# Visualize test_intersect_single_res seen in test_intersections.py - import pystare import numpy diff --git a/tests/test_intersections.py b/tests/test_intersections.py index 5fe7b30..4489d92 100644 --- a/tests/test_intersections.py +++ b/tests/test_intersections.py @@ -8,8 +8,7 @@ def triangulate(i0, i1, i2): "Prepare data structures for tri.Triangulate." - # print('triangulating...') - # i0,i1,i2,ic = ps.to_vertices(indices) + i0lat, i0lon = pystare.to_latlon(i0) i1lat, i1lon = pystare.to_latlon(i1) i2lat, i2lon = pystare.to_latlon(i2) @@ -34,7 +33,7 @@ def triangulate(i0, i1, i2): def triangulate1(lats,lons): "Prepare data for tri.Triangulate." - # print('triangulating1...') + intmat = [] npts = int(len(lats)/3) k = 0 diff --git a/tests/test_issue36.py b/tests/test_issue36.py new file mode 100644 index 0000000..274104d --- /dev/null +++ b/tests/test_issue36.py @@ -0,0 +1,110 @@ +import pystare +import numpy + + +sids = numpy.array([4257027547771961349, 4255901647865118726, 4256183122841829382, + 4257731235213737990, 4258012710190448646, 4280671445815656454, + 4280812183304011782, 4281093658280722438, 4281234395769077766, + 4281515870745788422, 4281656608234143750, 4282641770652631046, + 4280988105164455943, 4281410317629521927, 4281445502001610759, + 4281480686373699591, 4282430664420098055, 4282782508140986375, + 4541880224203145223, 4254212798004854792, 4254221594097877000, + 4254230390190899208, 4254239186283921416, 4254291962842054664, + 4254327147214143496, 4254335943307165704, 4254344739400187912, + 4256420617353429000, 4256429413446451208, 4256438209539473416, + 4256447005632495624, 4256455801725517832, 4256605335306895368, + 4256614131399917576, 4256631723585961992, 4256640519678984200, + 4256658111865028616, 4256666907958050824, 4256746072795250696, + 4256763664981295112, 4256772461074317320, 4256816441539428360, + 4256825237632450568, 4256842829818494984, 4256860422004539400, + 4256886810283606024, 4257590497725382664, 4257599293818404872, + 4257696050841649160, 4257704846934671368, 4257713643027693576, + 4257722439120715784, 4257871972702093320, 4257880768795115528, + 4257889564888137736, 4257898360981159944, 4257942341446270984, + 4257951137539293192, 4257959933632315400, 4257968729725337608, + 4258320573446225928, 4258364553911336968, 4258373350004359176, + 4258382146097381384, 4258390942190403592, 4258399738283425800, + 4258408534376448008, 4258426126562492424, 4258646028888047624, + 4258654824981069832, 4258672417167114248, 4258997872608935944, + 4260123772515778568, 4271664246560915464, 4271673042653937672, + 4271681838746959880, 4271690634839982088, 4271699430933004296, + 4271717023119048712, 4271725819212070920, 4271787391863226376, + 4271822576235315208, 4271875352793448456, 4271884148886470664, + 4271901741072515080, 4271919333258559496, 4272156827770159112, + 4280961716885389320, 4280970512978411528, 4280979309071433736, + 4281023289536544776, 4281032085629566984, 4281040881722589192, + 4281049677815611400, 4281058473908633608, 4281067270001655816, + 4281076066094678024, 4281084862187700232, 4281375133257433096, + 4281383929350455304, 4281392725443477512, 4281401521536499720, + 4282149189443387400, 4282360295675920392, 4282369091768942600, + 4282377887861964808, 4282386683954987016, 4282395480048009224, + 4282404276141031432, 4282413072234053640, 4282421868327075848, + 4282465848792186888, 4282474644885209096, 4282483440978231304, + 4282492237071253512, 4282536217536364552, 4282545013629386760, + 4282553809722408968, 4282562605815431176, 4282571401908453384, + 4282588994094497800, 4282597790187520008, 4282606586280542216, + 4282852876885164040, 4282861672978186248, 4282870469071208456, + 4282879265164230664, 4284049145536184328, 4284057941629206536, + 4284075533815250952, 4284101922094317576, 4284110718187339784, + 4285192637629071368, 4285201433722093576, 4285210229815115784, + 4285219025908137992, 4285227822001160200, 4285236618094182408, + 4285280598559293448, 4285289394652315656, 4285298190745337864, + 4285306986838360072, 4285465316512759816, 4285491704791826440, + 4285509296977870856, 4285518093070893064, 4285579665722048520, + 4285588461815070728, 4285632442280181768, 4285641238373203976, + 4285658830559248392, 4285667626652270600, 4285685218838315016, + 4285694014931337224, 4285702811024359432, 4541933000761278472, + 4541950592947322888, 4541959389040345096, 4541968185133367304, + 4541976981226389512, 4541985777319411720, 4541994573412433928, + 4542003369505456136, 4542012165598478344, 4542196883551944712, + 4542337621040300040, 4542346417133322248, 4542364009319366664, + 4553139223271571464, 4571153621781053448, 4571171213967097864, + 4571180010060120072, 4571232786618253320, 4571267970990342152]) + + +def test_all(): + # double free or corruption (!prev) + test_sids = sids + pystare.intersection(test_sids, test_sids, False) + + +def test_1(): + # free(): invalid size + test_sids = sids[0:-4] + pystare.intersection(test_sids, test_sids, False) + + +def test_2(): + # Segmentation fault (core dumped) + test_sids = sids[0:20] + pystare.intersection(test_sids, test_sids, False) + + +def test_3(): + # corrupted size vs. prev_size + sids = numpy.array([4257027547771961349, 4255901647865118726, 4256183122841829382, + 4257731235213737990, 4258012710190448646, 4280671445815656454, + 4256359044702273543, 4257625682097471495, 4257907157074182151, + 4280988105164455943, 4281410317629521927, 4281445502001610759, + 4281480686373699591, 4282430664420098055, 4282782508140986375, + 4282817692513075207, 4282888061257252871, 4285245414187204615, + 4541880224203145223, 4254212798004854792, 4254221594097877000, + 4254230390190899208, 4254239186283921416, 4254291962842054664, + 4254327147214143496, 4254335943307165704, 4254344739400187912, + ]) + pystare.intersection(sids, sids, False) + + +def test_4(): + # Segmentation fault (core dumped) + sids = numpy.array([4256183122841829382, 4541880224203145223, 4254221594097877000]) + pystare.intersection(sids, sids, False) + + +def test_5(): + sids = numpy.array([4541880224203145223, 4254221594097877000]) + res = pystare.intersection(sids, sids, False) + numpy.testing.assert_array_equal(sids, res) + + +test_3() \ No newline at end of file diff --git a/tests/test_spatial.py b/tests/test_spatial.py index 72d5188..d464505 100644 --- a/tests/test_spatial.py +++ b/tests/test_spatial.py @@ -1,6 +1,7 @@ import numpy import pystare import unittest +import tests.data.intervals class MainTest(unittest.TestCase): @@ -120,9 +121,8 @@ def test_cmpspatial(self): numpy.testing.assert_array_equal(compared, expected) def test__expand(self): - import tests.data.intervals as intervals - src = numpy.array(intervals.src, dtype=numpy.int64) - expected_expanded = numpy.array(intervals.expanded_src, dtype=numpy.int64) + src = numpy.array(tests.data.intervals.src, dtype=numpy.int64) + expected_expanded = numpy.array(tests.data.intervals.expanded_src, dtype=numpy.int64) expanded = numpy.zeros([len(expected_expanded)], dtype=numpy.int64) expanded_len = numpy.zeros([1], dtype=numpy.int64) intervals_len = len(src) @@ -138,9 +138,8 @@ def test__expand(self): self.assertFalse(error_found) def test_expand(self): - import tests.data.intervals as intervals - src = numpy.array(intervals.src, dtype=numpy.int64) - expected_expanded = numpy.array(intervals.expanded_src, dtype=numpy.int64) + src = numpy.array(tests.data.intervals.src, dtype=numpy.int64) + expected_expanded = numpy.array(tests.data.intervals.expanded_src, dtype=numpy.int64) resolution = -1 expanded = pystare.expand_intervals(src, resolution, multi_resolution=False) error_found = False diff --git a/tests/test_srange.py b/tests/test_srange.py index 0ed3a39..eecc659 100644 --- a/tests/test_srange.py +++ b/tests/test_srange.py @@ -1,6 +1,7 @@ import numpy import pystare import unittest +import tests.data.srange_data class MainTest(unittest.TestCase): @@ -11,20 +12,11 @@ def test_bug38(self): numpy.testing.assert_array_equal(sids, pystare.to_compressed_range(sids)) def test_make_srange1000(self): - try: - from tests.data.sids import sids - except: - from tests.data.sids import sids - pass - sids = sids[0:1000] + sids = tests.data.srange_data.sids[0:1000] srange = pystare.core.srange(sids) def test_make_srange10000(self): - try: - from tests.data.sids import sids - except: - from tests.data.sids import sids - pass + sids = tests.data.srange_data.sids[0:1000] sids = sids[0:10000] srange = pystare.core.srange(sids) diff --git a/tests/test_temporal.py b/tests/test_temporal.py index 6cb1e9a..727ca1b 100644 --- a/tests/test_temporal.py +++ b/tests/test_temporal.py @@ -170,7 +170,4 @@ def test_variable_res(self): for j in range(3): self.assertEqual(expected[i][j],i_varres_str[i][j]) -if __name__ == "__main__": - unittest.main() - diff --git a/tests/test_temporal_tai.py b/tests/test_temporal_tai.py index a2fd845..8b6eeb7 100644 --- a/tests/test_temporal_tai.py +++ b/tests/test_temporal_tai.py @@ -154,6 +154,3 @@ def test_a(self): for s in zip(['1970-01-01T00:00:08.000', '2000-01-01T00:00:32.000', '2002-02-03T13:56:35.172', '2016-01-05T17:26:36.172'], pystare.to_stare_timestring(tivs)): self.assertEqual(s[0],s[1][0:-12]) - -if __name__ == '__main__': - unittest.main()