Commit 67a2d229 authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

Time processing tests implemented - bugs fixed

This is a legacy commit from before 2015-05-18.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

csbackgen now behaves equal to the unix 'find' command.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 5328
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 0e2ce684
......@@ -28,6 +28,8 @@
# 13/02/2013 V0.5 added csbackresc.py and ssh/scp specific checks
# 14/02/2013 V0.6 added csclean.sh
# 28/02/2013 V0.7 added csbackscp.py
# 08/11/2013 V0.8 several csbackgen.py tests implemented which are related to
# the time exclusion commandline arguments
#
# ----------------------------------------------------------------------------
PROGRAMS=csback2cron.py csbackntfy.py csbackgen.py csbackchk.py csbackobs.py \
......@@ -159,11 +161,26 @@ package:
# generate directory with sample files
TESTDIR=testdir
TESTRESULTDIR=testResults
TESTS=$(addprefix test, $(shell seq 0 13))
NOW=$(shell date +"%Y%m%d%H%M")
TWOMINUTESAGO=$(shell date --date "now 2 minutes ago" +"%Y%m%d%H%M")
TWOANDHALFMINUTESAGO=$(shell date --date "now 2 minutes ago 30 seconds ago" \
+"%Y%m%d%H%M")
THREEMINUTESAGO=$(shell date --date "now 3 minutes ago" +"%Y%m%d%H%M")
FOURMINUTESAGO=$(shell date --date "now 4 minutes ago" +"%Y%m%d%H%M")
HALFDAYAGO=$(shell date --date "now 12 hours ago" +"%Y%m%d%H%M")
ONEDAYAGO=$(shell date --date "now 1 days ago" +"%Y%m%d%H%M")
ONEDAYAGO=$(shell date --date "now 1 day ago" +"%Y%m%d%H%M")
ONEDAYONEMINUTEAGO=$(shell date --date "now 1 day ago 1 minute ago" \
+"%Y%m%d%H%M")
ONEDAYMINUSONEMINUTEAGO=$(shell date --date "now 23 hours ago 59 minutes ago" \
+"%Y%m%d%H%M")
ONEDAYMINUSTWOMINUTESAGO=$(shell date --date "now 23 hours ago 58 minutes ago" \
+"%Y%m%d%H%M")
TWODAYSAGO=$(shell date --date "now 2 days ago" +"%Y%m%d%H%M")
THREEDAYSAGO=$(shell date --date "now 3 days ago" +"%Y%m%d%H%M")
.PHONY: testclean
testclean:
rm -rfv $(TESTDIR)
rm -rfv $(TESTRESULTDIR)
......@@ -178,97 +195,286 @@ $(TESTDIR)/now: $(TESTDIR)
touch -t $(NOW) $@
$(TESTDIR)/halfDayAgo: $(TESTDIR)
touch -t $(HALFDAYAGO) $@
$(TESTDIR)/twoMinutesAgo: $(TESTDIR)
touch -t $(TWOMINUTESAGO) $@
$(TESTDIR)/threeMinutesAgo: $(TESTDIR)
touch -t $(THREEMINUTESAGO) $@
$(TESTDIR)/twoAndHalfMinutesAgo: $(TESTDIR)
touch -t $(TWOANDHALFMINUTESAGO) $@
$(TESTDIR)/fourMinutesAgo: $(TESTDIR)
touch -t $(FOURMINUTESAGO) $@
$(TESTDIR)/oneDayAgo: $(TESTDIR)
touch -t $(ONEDAYAGO) $@
$(TESTDIR)/twoDaysAgo: $(TESTDIR)
touch -t $(TWODAYSAGO) $@
$(TESTDIR)/threeDaysAgo: $(TESTDIR)
touch -t $(THREEDAYSAGO) $@
$(TESTDIR)/oneDayOneMinuteAgo: $(TESTDIR)
touch -t $(ONEDAYONEMINUTEAGO) $@
$(TESTDIR)/oneDayMinusOneMinuteAgo: $(TESTDIR)
touch -t $(ONEDAYMINUSONEMINUTEAGO) $@
$(TESTDIR)/oneDayMinusTwoMinutesAgo: $(TESTDIR)
touch -t $(ONEDAYMINUSTWOMINUTESAGO) $@
.PHONY: testEnv
testEnv: $(TESTDIR)/now $(TESTDIR)/halfDayAgo $(TESTDIR)/oneDayAgo \
$(TESTDIR)/twoDaysAgo
testEnv: $(addprefix $(TESTDIR)/, now halfDayAgo oneDayAgo twoDaysAgo \
oneDayOneMinuteAgo oneDayMinusOneMinuteAgo oneDayMinusTwoMinutesAgo \
threeDaysAgo twoMinutesAgo threeMinutesAgo fourMinutesAgo \
twoAndHalfMinutesAgo)
tests: test1 test2 test3 test4
tests: $(TESTS)
testlst: $(TESTRESULTDIR)/test1.result $(TESTRESULTDIR)/test2.result \
$(TESTRESULTDIR)/test3.result $(TESTRESULTDIR)/test4.result
testlst: $(addprefix $(TESTRESULTDIR)/, $(addsuffix .result, $(TESTS)))
@echo -ne "----\n"
@cat $^
%.result: %.csbackgen.result %.find.result
ifeq ($(CONFIG),"")
$(warning WARNING: Variable CONFIG not set.)
$(eval CONFIG:=$(shell echo "undefined"))
endif
testID="$(shell basename -s .result $@ | tr -d '[:alpha:]')"; \
if [ -z "$(shell diff $^)" ]; then \
echo "TEST $${testID}: OK" > $@; \
echo "TEST $${testID}: OK ($(CONFIG))" > $@; \
else \
echo "TEST $${testID}: ERROR" > $@; \
echo "TEST $${testID}: ERROR ($(CONFIG))" > $@; \
fi
test0: $(TESTRESULTDIR)/test0.result
$(TESTRESULTDIR)/test0.result: $(TESTRESULTDIR)/test0.csbackgen.result \
$(TESTRESULTDIR)/test0.find.result
$(TESTRESULTDIR)/test0.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mtime 0"))
$(eval FIND_CONFIG:= $(shell echo "-mtime 0"))
@echo -ne "----\n"
@echo -ne "TEST 0: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
$(TESTRESULTDIR)/test0.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) -type f $(FIND_CONFIG) -printf "%f\n" | sort > $@
test1: $(TESTRESULTDIR)/test1.result
$(TESTRESULTDIR)/test1.result: $(TESTRESULTDIR)/test1.csbackgen.result \
$(TESTRESULTDIR)/test1.find.result
$(TESTRESULTDIR)/test1.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mtime 1"))
$(eval FIND_CONFIG:= $(shell echo "-mtime 1"))
@echo -ne "----\n"
@echo -ne "TEST 1: Excluding files last modified within the last \
24 hs (--mtime 0).\n"
@echo -ne "TEST 1: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug --mtime 0 $(word 2,$^) | \
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | \
sort | grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test1.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) -type f -mtime 0 -printf "%f\n" | sort > $@
find $(word 2,$^) -type f $(FIND_CONFIG) -printf "%f\n" | sort > $@
test2: $(TESTRESULTDIR)/test2.result
$(TESTRESULTDIR)/test2.result: $(TESTRESULTDIR)/test2.csbackgen.result \
$(TESTRESULTDIR)/test2.find.result
$(TESTRESULTDIR)/test2.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mtime -1"))
$(eval FIND_CONFIG:= $(shell echo "-mtime -1"))
@echo -ne "----\n"
@echo -ne "TEST 2: Excluding files last within the last 24 hs (--mtime -1).\n"
@echo -ne "TEST 2: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug --mtime 0 $(word 2,$^) | \
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
$(TESTRESULTDIR)/test2.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) -type f -mtime -1 -printf "%f\n" | sort > $@
find $(word 2,$^) -type f $(FIND_CONFIG) -printf "%f\n" | sort > $@
test3: $(TESTRESULTDIR)/test3.result
$(TESTRESULTDIR)/test3.result: $(TESTRESULTDIR)/test3.csbackgen.result \
$(TESTRESULTDIR)/test3.find.result
$(TESTRESULTDIR)/test3.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mtime +1"))
$(eval FIND_CONFIG:= $(shell echo "-mtime +1"))
@echo -ne "----\n"
@echo -ne "TEST 3: Excluding files last modified yesterday \
(--daystart --mtime 1).\n"
@echo -ne "TEST 3: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug --daystart --mtime 1 $(word 2,$^) | \
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | \
sort | grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test3.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) -daystart -type f -mtime 1 -printf "%f\n" | sort > $@
find $(word 2,$^) -type f $(FIND_CONFIG) -printf "%f\n" | sort > $@
test4: $(TESTRESULTDIR)/test4.result
$(TESTRESULTDIR)/test4.result: $(TESTRESULTDIR)/test4.csbackgen.result \
$(TESTRESULTDIR)/test4.find.result
$(TESTRESULTDIR)/test4.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mtime +1 --mtime -3"))
$(eval FIND_CONFIG:= $(shell echo "-mtime +1 -mtime -3"))
@echo -ne "----\n"
@echo -ne "TEST 4: Excluding files last modified 24 hs ago and earlier \
(--mtime +1).\n"
@echo -ne "TEST 4: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug --mtime +1 $(word 2,$^) | \
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test4.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) -type f -mtime +1 -printf "%f\n" | sort > $@
find $(word 2,$^) -type f $(FIND_CONFIG) -printf "%f\n" | sort > $@
# --daystart related tests
test5: $(TESTRESULTDIR)/test5.result
$(TESTRESULTDIR)/test5.result: $(TESTRESULTDIR)/test5.csbackgen.result \
$(TESTRESULTDIR)/test5.find.result
$(TESTRESULTDIR)/test5.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--daystart --mtime 0"))
$(eval FIND_CONFIG:= $(shell echo "-daystart -type f -mtime 0"))
@echo -ne "----\n"
@echo -ne "TEST 5: Excluding files last modified less than 2 days ago.\n"
@echo -ne "TEST 5: $(CONFIG)\n"
@echo -ne "----\n"
$(TESTRESULTDIR)/test5.find.result:
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
$(TESTRESULTDIR)/test5.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test6: $(TESTRESULTDIR)/test6.result
$(TESTRESULTDIR)/test6.result: $(TESTRESULTDIR)/test6.csbackgen.result \
$(TESTRESULTDIR)/test6.find.result
$(TESTRESULTDIR)/test6.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--daystart --mtime 1"))
$(eval FIND_CONFIG:= $(shell echo "-daystart -type f -mtime 1"))
@echo -ne "----\n"
@echo -ne "TEST 6: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test6.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test7: $(TESTRESULTDIR)/test7.result
$(TESTRESULTDIR)/test7.result: $(TESTRESULTDIR)/test7.csbackgen.result \
$(TESTRESULTDIR)/test7.find.result
$(TESTRESULTDIR)/test7.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--daystart --mtime -2"))
$(eval FIND_CONFIG:= $(shell echo "-daystart -type f -mtime -2"))
@echo -ne "----\n"
@echo -ne "TEST 7: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
$(TESTRESULTDIR)/test7.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test8: $(TESTRESULTDIR)/test8.result
$(TESTRESULTDIR)/test8.result: $(TESTRESULTDIR)/test8.csbackgen.result \
$(TESTRESULTDIR)/test8.find.result
$(TESTRESULTDIR)/test8.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--daystart --mtime +1"))
$(eval FIND_CONFIG:= $(shell echo "-daystart -type f -mtime +1"))
@echo -ne "----\n"
@echo -ne "TEST 8: $(CONFIG)\n"
@echo -ne "----\n"
@echo -ne "TEST 6: Excluding files last modified in between \
24h and 48h ago.\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e 'checksumfile.cs' > $@
$(TESTRESULTDIR)/test8.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test9: $(TESTRESULTDIR)/test9.result
$(TESTRESULTDIR)/test9.result: $(TESTRESULTDIR)/test9.csbackgen.result \
$(TESTRESULTDIR)/test9.find.result
$(TESTRESULTDIR)/test9.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--daystart --mtime +1 --mtime -3"))
$(eval FIND_CONFIG:= $(shell echo "-daystart -mtime +1 -mtime -3"))
@echo -ne "----\n"
@echo -ne "TEST 9: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test9.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test10: $(TESTRESULTDIR)/test10.result
$(TESTRESULTDIR)/test10.result: $(TESTRESULTDIR)/test10.csbackgen.result \
$(TESTRESULTDIR)/test10.find.result
$(TESTRESULTDIR)/test10.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mmin 3"))
$(eval FIND_CONFIG:= $(shell echo "-type f -mmin 3"))
@echo -ne "----\n"
@echo -ne "TEST 10: $(CONFIG)\n"
@echo -ne "----\n"
$(TESTRESULTDIR)/test6.find.result:
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test10.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test11: $(TESTRESULTDIR)/test11.result
$(TESTRESULTDIR)/test11.result: $(TESTRESULTDIR)/test11.csbackgen.result \
$(TESTRESULTDIR)/test11.find.result
$(TESTRESULTDIR)/test11.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mmin -3"))
$(eval FIND_CONFIG:= $(shell echo "-type f -mmin -3"))
@echo -ne "----\n"
@echo -ne "TEST 11: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort > $@
$(TESTRESULTDIR)/test11.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test12: $(TESTRESULTDIR)/test12.result
$(TESTRESULTDIR)/test12.result: $(TESTRESULTDIR)/test12.csbackgen.result \
$(TESTRESULTDIR)/test12.find.result
$(TESTRESULTDIR)/test12.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mmin +2"))
$(eval FIND_CONFIG:= $(shell echo "-type f -mmin +2"))
@echo -ne "----\n"
@echo -ne "TEST 12: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test12.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test13: $(TESTRESULTDIR)/test13.result
$(TESTRESULTDIR)/test13.result: $(TESTRESULTDIR)/test13.csbackgen.result \
$(TESTRESULTDIR)/test13.find.result
$(TESTRESULTDIR)/test13.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mmin +1 --mmin -3"))
$(eval FIND_CONFIG:= $(shell echo "-type f -mmin +1 -mmin -3"))
@echo -ne "----\n"
@echo -ne "TEST 13: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test13.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
test14: $(TESTRESULTDIR)/test14.result
$(TESTRESULTDIR)/test14.result: $(TESTRESULTDIR)/test14.csbackgen.result \
$(TESTRESULTDIR)/test14.find.result
$(TESTRESULTDIR)/test14.csbackgen.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
$(eval CONFIG:= $(shell echo "--mmin 0"))
$(eval FIND_CONFIG:= $(shell echo "-type f -mmin 0"))
@echo -ne "----\n"
@echo -ne "TEST 14: $(CONFIG)\n"
@echo -ne "----\n"
csbackgen -n --debug $(CONFIG) $(word 2,$^) | \
sed -n '/List of excluded files:/,/308/p' | sed -e '1d' -e '$$d' | \
awk '{$$1=$$2=$$3=""; print $$0}' | sed -e 's/^[[:space:]]*//' | sort | \
grep -v -e "checksumfile.cs" > $@
$(TESTRESULTDIR)/test14.find.result: testEnv $(TESTDIR) $(TESTRESULTDIR)
find $(word 2,$^) $(FIND_CONFIG) -printf "%f\n" | sort > $@
# ----- END OF Makefile -----
......@@ -46,6 +46,7 @@
# 12/03/2013 V0.6.1 BUG in CsFile.check() function fixed
# 14/03/2013 V0.6.2 make use with statement
# 26/10/2013 V0.6.3 increase verbosity in debug mode (CsFile.update())
# 08/11/2013 V0.6.4 Time processing bugs fixed.
#
# =============================================================================
""" CsFile module to handle checksumfiles. """
......@@ -552,6 +553,7 @@ class CsTimeProcessor:
"""
try:
start = datetime.now()
#start = now-timedelta(microseconds=now.microsecond)
if self.daystart:
t = time(0)
start = datetime.combine(date.today(),t)
......@@ -576,11 +578,14 @@ class CsTimeProcessor:
elif abs(minPlus) == abs(minMinus):
pass
else:
self.result.append((start+timedelta(minutes=minMinus), \
start-timedelta(minutes=minPlus)))
if 0 == minPlus:
self.result.append((start+timedelta(minutes=minMinus), start))
else:
self.result.append((start+timedelta(minutes=minMinus), \
start-timedelta(minutes=minPlus+1)))
for min in minFixed:
self.result.append((start-timedelta(minutes=min+1), \
start-timedelta(minutes=min)))
self.result.append((start-timedelta(minutes=min), \
start-timedelta(minutes=min-1)))
except TypeError as err:
raise CsFileError(514,str(err))
except OverflowError as err:
......@@ -616,7 +621,8 @@ class StandardTimeProcessor(TimeProcessor):
"""
def processTime(self):
try:
start = datetime.now()
now = datetime.now()
start = now-timedelta(microseconds=now.microsecond)
timePlus = 0
timeMinus = 0
timeFixed = []
......@@ -631,14 +637,17 @@ class StandardTimeProcessor(TimeProcessor):
timeFixed.append(int(t))
if abs(timePlus) > abs(timeMinus):
if 0 != timePlus:
self.result.append((datetime.min, start-timedelta(days=timePlus)))
self.result.append((datetime.min, start-timedelta(days=timePlus+1)))
if 0 != timeMinus:
self.result.append((start+timedelta(days=timeMinus), start))
elif abs(timePlus) == abs(timeMinus):
pass
else:
self.result.append((start+timedelta(days=timeMinus), \
start-timedelta(days=timePlus)))
if 0 == timePlus:
self.result.append((start+timedelta(days=timeMinus), start))
else:
self.result.append((start+timedelta(days=timeMinus), \
start-timedelta(days=timePlus+1)))
for t in timeFixed:
self.result.append((start-timedelta(days=t+1), \
start-timedelta(days=t)))
......@@ -685,10 +694,10 @@ class DaystartTimeProcessor(TimeProcessor):
# case 3:
# ------------|======================|--------------|--------->
# ^ ^ ^ t
# include | exclude | include |
# daystart+timeMinus daystart-timePlus now
# include | exclude | include | include
# daystart+timeMinus+1 daystart-timePlus now
else:
self.result.append((start+timedelta(days=timeMinus[-1]), \
self.result.append((start+timedelta(days=timeMinus[-1]+1), \
start-timedelta(days=timePlus[-1])))
# case 4:
# ============|------------|---------->
......@@ -697,30 +706,31 @@ class DaystartTimeProcessor(TimeProcessor):
# daystart-timePlus now
elif len(timePlus) and 0 == len(timeMinus):
self.result.append((datetime.min, start-timedelta(days=timePlus[-1])))
# case 5:
# ------------|============|---------->
# ^ ^ t
# include | exclude | include
# daystart+timeMinus now
# daystart+timeMinus+1 now
elif 0 == len(timePlus) and len(timeMinus):
self.result.append((start-timedelta(days=timeMinus[-1]), \
self.result.append((start+timedelta(days=timeMinus[-1]+1), \
datetime.now()))
for t in timeFixed:
if 0 == t:
# case 6:
# ----------------|===========|------------->
# ^ ^ t
# | |
# include daystart now
# | exclude |
# daystart now
self.result.append((start, datetime.now()))
else:
# case 7:
# ----------------|==================|---------|--------->
# ^ ^ ^ t
# | | |
# include daystart-(days+1) daystart-days now
self.result.append((start-timedelta(days=t+1), \
start-timedelta(days=t)))
# ^ ^ ^ t
# | exclude | |
# daystart-days daystart-days+1 now
self.result.append((start-timedelta(days=t), \
start-timedelta(days=t-1)))
except TypeError as err:
raise CsFileError(str(err), eCodes.CSFILE_TimeProcessingTypeError)
except OverflowError as err:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment