diff options
| author | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-04-10 19:20:48 +0000 |
|---|---|---|
| committer | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-04-10 19:20:48 +0000 |
| commit | 160cc1e115eeb75638dce6effdd16b2bc810ddb4 (patch) | |
| tree | b791a95695a7cf674e61a6153139c6f9c6c491fa /tests | |
| parent | 3843727e74b31bbf2a34e7e3b89ee422269f770e (diff) | |
| parent | 413a6aa6469e6c297780217a27ca91363c637944 (diff) | |
| download | fpc-avr.tar.gz | |
* rebase to trunk@17295avr
git-svn-id: http://svn.freepascal.org/svn/fpc/branches/avr@17296 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Makefile | 61 | ||||
| -rw-r--r-- | tests/Makefile.fpc | 56 | ||||
| -rw-r--r-- | tests/tbf/tb0220.pp | 8 | ||||
| -rw-r--r-- | tests/test/cg/obj/win32/i386/cpptcl2.o | bin | 0 -> 406 bytes | |||
| -rw-r--r-- | tests/test/cg/obj/win32/i386/tcext6.o | bin | 0 -> 3369 bytes | |||
| -rw-r--r-- | tests/test/taes1.pp | 190 | ||||
| -rw-r--r-- | tests/test/tarray8.pp | 27 | ||||
| -rw-r--r-- | tests/test/tarray9.pp | 122 | ||||
| -rw-r--r-- | tests/test/tclass13.pp | 12 | ||||
| -rw-r--r-- | tests/test/tclass13a.pp | 17 | ||||
| -rw-r--r-- | tests/test/tclass13b.pp | 23 | ||||
| -rw-r--r-- | tests/test/tindex.pp | 36 | ||||
| -rw-r--r-- | tests/test/tsec1.pp | 6 | ||||
| -rw-r--r-- | tests/test/units/system/tmem.pp | 74 | ||||
| -rw-r--r-- | tests/webtbs/tw16040.pp | 66 | ||||
| -rw-r--r-- | tests/webtbs/tw18567.pp (renamed from tests/webtbs/tw18567) | 0 | ||||
| -rw-r--r-- | tests/webtbs/tw18702.pp | 38 | ||||
| -rw-r--r-- | tests/webtbs/tw18859.pp | 38 |
18 files changed, 732 insertions, 42 deletions
diff --git a/tests/Makefile b/tests/Makefile index a1bfda3256..9e871692cd 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,8 +1,8 @@ # -# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/29] +# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/03/23] # default: allexectests -MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux +MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux BSDs = freebsd netbsd openbsd darwin UNIXs = linux $(BSDs) solaris qnx haiku LIMIT83fs = go32v2 os2 emx watcom @@ -611,6 +611,11 @@ ifeq ($(OS_TARGET),NativeNT) SHAREDLIBEXT=.dll SHORTSUFFIX=nativent endif +ifeq ($(OS_TARGET),wii) +EXEEXT=.dol +SHAREDLIBEXT=.so +SHORTSUFFIX=wii +endif else ifeq ($(OS_TARGET),go32v1) PPUEXT=.pp1 @@ -1503,24 +1508,43 @@ PREPUP=utils/prepup endif units: $(MAKE) -C units FPC_VERSION= FPC=$(TEST_FPC) CPU_TARGET=$(TEST_CPU_TARGET) OS_TARGET=$(TEST_OS_TARGET) OPT="$(TEST_OPT)" CCOMPILER=$(TEST_CCOMPILER) BINUTILSPREFIX=$(TEST_BINUTILSPREFIX) -copyfiles: $(TEST_OUTPUTDIR) +.PHONY: create_c_objects delete_c_objects copyfiles +C_SOURCE_DIR=test/cg/obj +C_SOURCES=ctest.c tcext3.c tcext4.c tcext5.c tcext6.c +CPP_SOURCES=cpptcl1.cpp cpptcl2.cpp ifneq ($(TEST_ABI),) - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/ctest.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext3.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext4.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext5.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext6.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/cpptcl1.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/cpptcl2.o test/cg -else - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/ctest.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext3.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext4.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext5.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext6.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/cpptcl1.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/cpptcl2.o test/cg +C_OBJECTS_DIR=$(C_SOURCE_DIR)/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI) +else +C_OBJECTS_DIR=$(C_SOURCE_DIR)/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET) endif +C_OBJECTS=$(addprefix $(C_OBJECTS_DIR)/, $(subst .c,.o, $(C_SOURCES))) +CPP_OBJECTS=$(addprefix $(C_OBJECTS_DIR)/, $(subst .cpp,.o, $(CPP_SOURCES))) +create_c_objects: +ifneq ($(TEST_CCOMPILER),) + -$(COPY) $(addprefix $(C_SOURCE_DIR)/, $(C_SOURCES)) $(C_OBJECTS_DIR) + $(MAKE) $(C_OBJECTS) + -$(COPY) $(addprefix $(C_SOURCE_DIR)/, $(CPP_SOURCES)) $(C_OBJECTS_DIR) + $(MAKE) $(CPP_OBJECTS) + -$(DEL) $(addprefix $(C_OBJECTS_DIR)/, $(C_SOURCES) $(CPP_SOURCES)) +else + $(ECHO) create_c_objects rule needs a valid C compiler in TEST_CCOMPILER variable + $(ECHO) TEST_CFLAGS variable is passed as options is used to compile the objects +endif +delete_c_objects: +ifneq ($(TEST_CCOMPILER),) + -$(DEL) $(C_OBJECTS) $(CPP_OBJECTS) +else + $(ECHO) delete_c_objects rule needs a valid C compiler in TEST_CCOMPILER variable + $(ECHO) to be able to recompile the objects using create_objects rule. +endif +$(C_OBJECTS) : %.o: %.c + $(TEST_CCOMPILER) -c $(TEST_CFLAGS) $< -o $@ +$(CPP_OBJECTS) : %.o: %.cpp + $(TEST_CCOMPILER) -c $(TEST_CFLAGS) $< -o $@ +copyfiles: $(TEST_OUTPUTDIR) + -$(MKDIRTREE) $(TEST_OUTPUTDIR)/test/cg + -$(COPY) $(C_OBJECTS) $(TEST_OUTPUTDIR)/test/cg + -$(COPY) $(CPP_OBJECTS) $(TEST_OUTPUTDIR)/test/cg -$(MKDIRTREE) $(TEST_OUTPUTDIR)/test/units/system $(COPY) test/units/system/test*.txt $(TEST_OUTPUTDIR)/test/units/system testprep: testprep-stamp.$(TEST_FULL_TARGET) @@ -1563,7 +1587,6 @@ endif ifdef TEST_VERBOSE override DOTESTOPT+=-V endif -# Also display benchmarks ifdef TEST_BENCH override DOTESTOPT+=-D endif diff --git a/tests/Makefile.fpc b/tests/Makefile.fpc index 19d2264e57..c4b3541df5 100644 --- a/tests/Makefile.fpc +++ b/tests/Makefile.fpc @@ -178,24 +178,50 @@ units: # Copy test environment dependent files ctest.o, cext3.o, cext4.o to test/cg etc # -copyfiles: $(TEST_OUTPUTDIR) +.PHONY: create_c_objects delete_c_objects copyfiles + +C_SOURCE_DIR=test/cg/obj +C_SOURCES=ctest.c tcext3.c tcext4.c tcext5.c tcext6.c +CPP_SOURCES=cpptcl1.cpp cpptcl2.cpp ifneq ($(TEST_ABI),) - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/ctest.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext3.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext4.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext5.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/tcext6.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/cpptcl1.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI)/cpptcl2.o test/cg +C_OBJECTS_DIR=$(C_SOURCE_DIR)/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)-$(TEST_ABI) +else +C_OBJECTS_DIR=$(C_SOURCE_DIR)/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET) +endif +C_OBJECTS=$(addprefix $(C_OBJECTS_DIR)/, $(subst .c,.o, $(C_SOURCES))) +CPP_OBJECTS=$(addprefix $(C_OBJECTS_DIR)/, $(subst .cpp,.o, $(CPP_SOURCES))) + + +create_c_objects: +ifneq ($(TEST_CCOMPILER),) + -$(COPY) $(addprefix $(C_SOURCE_DIR)/, $(C_SOURCES)) $(C_OBJECTS_DIR) + $(MAKE) $(C_OBJECTS) + -$(COPY) $(addprefix $(C_SOURCE_DIR)/, $(CPP_SOURCES)) $(C_OBJECTS_DIR) + $(MAKE) $(CPP_OBJECTS) + -$(DEL) $(addprefix $(C_OBJECTS_DIR)/, $(C_SOURCES) $(CPP_SOURCES)) else - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/ctest.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext3.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext4.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext5.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/tcext6.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/cpptcl1.o test/cg - -$(COPY) test/cg/obj/$(TEST_OS_TARGET)/$(TEST_CPU_TARGET)/cpptcl2.o test/cg + $(ECHO) create_c_objects rule needs a valid C compiler in TEST_CCOMPILER variable + $(ECHO) TEST_CFLAGS variable is passed as options is used to compile the objects endif + +delete_c_objects: +ifneq ($(TEST_CCOMPILER),) + -$(DEL) $(C_OBJECTS) $(CPP_OBJECTS) +else + $(ECHO) delete_c_objects rule needs a valid C compiler in TEST_CCOMPILER variable + $(ECHO) to be able to recompile the objects using create_objects rule. +endif + +$(C_OBJECTS) : %.o: %.c + $(TEST_CCOMPILER) -c $(TEST_CFLAGS) $< -o $@ + +$(CPP_OBJECTS) : %.o: %.cpp + $(TEST_CCOMPILER) -c $(TEST_CFLAGS) $< -o $@ + +copyfiles: $(TEST_OUTPUTDIR) + -$(MKDIRTREE) $(TEST_OUTPUTDIR)/test/cg + -$(COPY) $(C_OBJECTS) $(TEST_OUTPUTDIR)/test/cg + -$(COPY) $(CPP_OBJECTS) $(TEST_OUTPUTDIR)/test/cg -$(MKDIRTREE) $(TEST_OUTPUTDIR)/test/units/system $(COPY) test/units/system/test*.txt $(TEST_OUTPUTDIR)/test/units/system diff --git a/tests/tbf/tb0220.pp b/tests/tbf/tb0220.pp new file mode 100644 index 0000000000..72b9a22c91 --- /dev/null +++ b/tests/tbf/tb0220.pp @@ -0,0 +1,8 @@ +{ %fail } + +type + tset = set of byte; +begin + if 2 in tset then + writeln('should not compile') +end. diff --git a/tests/test/cg/obj/win32/i386/cpptcl2.o b/tests/test/cg/obj/win32/i386/cpptcl2.o Binary files differnew file mode 100644 index 0000000000..267eae5ca0 --- /dev/null +++ b/tests/test/cg/obj/win32/i386/cpptcl2.o diff --git a/tests/test/cg/obj/win32/i386/tcext6.o b/tests/test/cg/obj/win32/i386/tcext6.o Binary files differnew file mode 100644 index 0000000000..b4b4e77cd6 --- /dev/null +++ b/tests/test/cg/obj/win32/i386/tcext6.o diff --git a/tests/test/taes1.pp b/tests/test/taes1.pp new file mode 100644 index 0000000000..6f8a346a48 --- /dev/null +++ b/tests/test/taes1.pp @@ -0,0 +1,190 @@ +{ %CPU=x86_64 } +Program AESTest; +{$INLINE ON} +{$ASMMODE INTEL} +{$MODE DELPHI} + +Uses Cpu,SysUtils; + +Type + Word32 = LongWord; + Word64 = QWord; + WordPR = Word64; + + PAESKey256 = ^TAESKey256; TAESKey256 = Array [0..3] of Word64; + + PAESOpenedKey = ^TAESOpenedKey; TAESOpenedKey = Packed Record + EnCryptRoundKeys : Array [0..14, 0..3] Of Word32; + Padding0 : Array [0..3] of Word32; + DeCryptRoundKeys : Array [0..14, 0..3] Of Word32; + Padding1 : Array [0..3] of Word32; + End; + +Const + Test_Key : Array[0..3] of Word64 = ($0706050403020100, $0f0e0d0c0b0a0908, $1716151413121110, $1f1e1d1c1b1a1918); + Test_Data : Array[0..1] of Word64 = (Word64($7766554433221100), Word64($ffeeddccbbaa9988)); + Test_Crypt : Array[0..1] of Word64 = (Word64($bf456751cab7a28e), Word64($8960494b9049fcea)); + +Var + OpenedKey : TAESOpenedKey; + Data : Array [0..1] of Word64; + Passed : Boolean; + +Procedure OpenKey_AES(Key: PAESKey256; OpenedKey: PAESOpenedKey); Assembler; NoStackFrame; + Procedure key_expansion; Assembler; NoStackFrame; + Asm + MOV RDX, RCX + PSHUFD XMM2, XMM2, 011111111b; PXOR XMM2, XMM1; MOVD EAX, XMM2; MOV [RCX], EAX; ADD RCX, 4 + PSHUFD XMM1, XMM1, 011100101b; MOVD EBX, XMM1; XOR EAX, EBX; MOV [RCX], EAX; ADD RCX, 4 + PSHUFD XMM1, XMM1, 011100110b; MOVD EBX, XMM1; XOR EAX, EBX; MOV [RCX], EAX; ADD RCX, 4 + PSHUFD XMM1, XMM1, 011100111b; MOVD EBX, XMM1; XOR EAX, EBX; MOV [RCX], EAX; ADD RCX, 4 + MOVDQU XMM4, [RDX]; AESKEYGEN XMM4, XMM4, 0 + PSHUFD XMM4, XMM4, 011100110b; MOVD EAX, XMM4; MOVD EBX, XMM3; XOR EAX, EBX; MOV [RCX], EAX; ADD RCX, 4 + PSHUFD XMM3, XMM3, 011100101b; MOVD EBX, XMM3; XOR EAX, EBX; MOV [RCX], EAX; ADD RCX, 4 + PSHUFD XMM3, XMM3, 011100110b; MOVD EBX, XMM3; XOR EAX, EBX; MOV [RCX], EAX; ADD RCX, 4 + PSHUFD XMM3, XMM3, 011100111b; MOVD EBX, XMM3; XOR EAX, EBX; MOV [RCX], EAX; ADD RCX, 4 + MOVDQU XMM1, [RDX]; ADD RDX, $10; MOVDQU XMM3, [RDX] + End; +Asm + PUSH RBX +{$ifndef win64} + // fix parameter locations + MOV RDX,RSI + MOV RCX,RDI +{$endif win64} + MOV R8, RDX + MOVDQU XMM1, [RCX]; MOVDQU XMM3, [RCX+16] + MOVDQU [RDX], XMM1; MOVDQU [RDX + $10], XMM3 + LEA RCX, [RDX+$20] + AESKEYGEN XMM2, XMM3, $1; CALL key_expansion + AESKEYGEN XMM2, XMM3, $2; CALL key_expansion + AESKEYGEN XMM2, XMM3, $4; CALL key_expansion + AESKEYGEN XMM2, XMM3, $8; CALL key_expansion + AESKEYGEN XMM2, XMM3, $10; CALL key_expansion + AESKEYGEN XMM2, XMM3, $20; CALL key_expansion + AESKEYGEN XMM2, XMM3, $40; CALL key_expansion + MOVDQU XMM0, [R8+$00]; MOVDQU XMM1, [R8+$10]; MOVDQU XMM2, [R8+$20]; MOVDQU XMM3, [R8+$30] + MOVDQU XMM4, [R8+$40]; MOVDQU XMM5, [R8+$50]; MOVDQU XMM6, [R8+$60]; MOVDQU XMM7, [R8+$70] + MOVDQU XMM8, [R8+$80]; MOVDQU XMM9, [R8+$90]; MOVDQU XMM10, [R8+$A0]; MOVDQU XMM11, [R8+$B0] + MOVDQU XMM12, [R8+$C0]; MOVDQU XMM13, [R8+$D0]; MOVDQU XMM14, [R8+$E0] + AESIMC XMM1, XMM1; AESIMC XMM2, XMM2; AESIMC XMM3, XMM3; AESIMC XMM4, XMM4 + AESIMC XMM5, XMM5; AESIMC XMM6, XMM6; AESIMC XMM7, XMM7; AESIMC XMM8, XMM8 + AESIMC XMM9, XMM9; AESIMC XMM10, XMM10; AESIMC XMM11, XMM11; AESIMC XMM12, XMM12 + AESIMC XMM13, XMM13 + MOVDQU [R8+$100], XMM0; MOVDQU [R8+$110], XMM1; MOVDQU [R8+$120], XMM2; MOVDQU [R8+$130], XMM3 + MOVDQU [R8+$140], XMM4; MOVDQU [R8+$150], XMM5; MOVDQU [R8+$160], XMM6; MOVDQU [R8+$170], XMM7 + MOVDQU [R8+$180], XMM8; MOVDQU [R8+$190], XMM9; MOVDQU [R8+$1A0], XMM10; MOVDQU [R8+$1B0], XMM11 + MOVDQU [R8+$1C0], XMM12; MOVDQU [R8+$1D0], XMM13; MOVDQU [R8+$1E0], XMM14 + POP RBX +End; + +Procedure EnCrypt_AES(InData, OutData: Pointer; DataSize: WordPR; EnCryptRoundKeys: Pointer); Assembler; NoStackFrame; +Asm +{$ifndef win64} + // fix parameter locations + MOV R9,RCX + MOV R8,RDX + MOV RDX,RSI + MOV RCX,RDI +{$endif win64} + // Loading encryption keys + MOVDQU XMM0, [R9+16*0] + MOVDQU XMM1, [R9+16*1] + MOVDQU XMM2, [R9+16*2] + MOVDQU XMM3, [R9+16*3] + MOVDQU XMM4, [R9+16*4] + MOVDQU XMM5, [R9+16*5] + MOVDQU XMM6, [R9+16*6] + MOVDQU XMM7, [R9+16*7] + MOVDQU XMM8, [R9+16*8] + MOVDQU XMM9, [R9+16*9] + MOVDQU XMM10, [R9+16*10] + MOVDQU XMM11, [R9+16*11] + MOVDQU XMM12, [R9+16*12] + MOVDQU XMM13, [R9+16*13] + MOVDQU XMM14, [R9+16*14] + // Setting the main loop + XCHG RCX, R8 + SHR RCX, 4 +@Loop: MOVDQU XMM15, [R8]; ADD R8, 16 + PXOR XMM15, XMM0 + AESENC XMM15, XMM1 + AESENC XMM15, XMM2 + AESENC XMM15, XMM3 + AESENC XMM15, XMM4 + AESENC XMM15, XMM5 + AESENC XMM15, XMM6 + AESENC XMM15, XMM7 + AESENC XMM15, XMM8 + AESENC XMM15, XMM9 + AESENC XMM15, XMM10 + AESENC XMM15, XMM11 + AESENC XMM15, XMM12 + AESENC XMM15, XMM13 + AESENCLAST XMM15, XMM14 + MOVDQU [RDX], XMM15; ADD RDX, 16 + LOOP @Loop +End; + +Procedure DeCrypt_AES(InData, OutData: Pointer; DataSize: WordPR; DeCryptRoundKeys: Pointer); Assembler; NoStackFrame; +Asm +{$ifndef win64} + // fix parameter locations + MOV R9,RCX + MOV R8,RDX + MOV RDX,RSI + MOV RCX,RDI +{$endif win64} + // Loading decryption keys + MOVDQU XMM0, [R9+16*0] + MOVDQU XMM1, [R9+16*1] + MOVDQU XMM2, [R9+16*2] + MOVDQU XMM3, [R9+16*3] + MOVDQU XMM4, [R9+16*4] + MOVDQU XMM5, [R9+16*5] + MOVDQU XMM6, [R9+16*6] + MOVDQU XMM7, [R9+16*7] + MOVDQU XMM8, [R9+16*8] + MOVDQU XMM9, [R9+16*9] + MOVDQU XMM10, [R9+16*10] + MOVDQU XMM11, [R9+16*11] + MOVDQU XMM12, [R9+16*12] + MOVDQU XMM13, [R9+16*13] + MOVDQU XMM14, [R9+16*14] + // Setting the main loop + XCHG RCX, R8 + SHR RCX, 4 +@Loop: MOVDQU XMM15, [R8]; ADD R8, 16 + PXOR XMM15, XMM14 + AESDEC XMM15, XMM13 + AESDEC XMM15, XMM12 + AESDEC XMM15, XMM11 + AESDEC XMM15, XMM10 + AESDEC XMM15, XMM9 + AESDEC XMM15, XMM8 + AESDEC XMM15, XMM7 + AESDEC XMM15, XMM6 + AESDEC XMM15, XMM5 + AESDEC XMM15, XMM4 + AESDEC XMM15, XMM3 + AESDEC XMM15, XMM2 + AESDEC XMM15, XMM1 + AESDECLAST XMM15, XMM0 + MOVDQU [RDX], XMM15; ADD RDX, 16 + LOOP @Loop +End; + +BEGIN + if AESSupport then + begin + OpenKey_AES(@Test_Key, @OpenedKey); + EnCrypt_AES(@Test_Data, @Data, 16, @OpenedKey.EnCryptRoundKeys); + Passed := SysUtils.CompareMem(@Data, @Test_Crypt, 16); + DeCrypt_AES(@Data, @Data, 16, @OpenedKey.DeCryptRoundKeys); + Passed := Passed and SysUtils.CompareMem(@Data, @Test_Data, 16); + If Not Passed Then Halt(1); + writeln('ok'); + end + else + writeln('CPU has no AES instruction support'); +END. diff --git a/tests/test/tarray8.pp b/tests/test/tarray8.pp new file mode 100644 index 0000000000..3ce505c0f1 --- /dev/null +++ b/tests/test/tarray8.pp @@ -0,0 +1,27 @@ +{ Test correct RTTI handling of open arrays with managed elements. + See also webtbs/tw18859.pp } + +{$mode objfpc}{$h+} + +procedure test3(out arr: array of string); +begin + { implicit initialize happens here } + arr[0] := ''; // if initialization does not happen correctly, teststring will be destroyed +end; + +var + teststring: string; + arrs: array[0..3] of string; + +begin + teststring := 'test'; + uniquestring(teststring); + // Must be a string with refcount>1, otherwise decref before call will release it and + // zero the pointer, thus masking the issue. + arrs[0] := teststring; + { implicit decref happens here } + test3(arrs); + if teststring <> 'test' then + Halt(1); + Halt(0); +end. diff --git a/tests/test/tarray9.pp b/tests/test/tarray9.pp new file mode 100644 index 0000000000..2b3cab0ef9 --- /dev/null +++ b/tests/test/tarray9.pp @@ -0,0 +1,122 @@ +{ %OPT=-gh } + +{ Test correct RTTI handling of open arrays with managed elements. + When a part (slice or range) of array is passed as an out-parameter open array + to a procedure, the entire array should NOT be finalized, only part that is actually passed should. } + +{$mode objfpc}{$h+} +uses SysUtils; + + +procedure test3(out arr: array of string); +var + i: Integer; +begin + { implicit initialization happens here } + for i := 0 to High(arr) do + begin + Pointer(arr[i]):=nil; // if array initialization was correct, this will be a no-op + // otherwise, it will trigger a memory leak + arr[i] := 'tested'+IntToStr(i); + end; +end; + +procedure test_entire_openarray(var arr: array of string); +begin + test3(arr); +end; + +procedure test_openarray_subrange(var arr: array of string); +begin + test3(arr[1..2]); +end; + +procedure test_openarray_slice(var arr: array of string); +begin + test3(slice(arr,2)); +end; + + +var + sarr: array[0..3] of string; + darr: array of string; + +procedure prepare; +var + i: Integer; +begin + for i := 0 to 3 do + begin + sarr[i] := 'static'+IntToStr(i); + darr[i] := 'dynamic'+IntToStr(i); + end; +end; + +begin + HaltOnNotReleased := True; + SetLength(darr,4); + + prepare; + test_entire_openarray(sarr); + if sarr[0] <> 'tested0' then Halt(1); + if sarr[1] <> 'tested1' then Halt(2); + if sarr[2] <> 'tested2' then Halt(3); + if sarr[3] <> 'tested3' then Halt(4); + + prepare; + test_openarray_subrange(sarr); // must leave elements 0 and 3 intact + if sarr[0] <> 'static0' then Halt(11); + if sarr[1] <> 'tested0' then Halt(12); + if sarr[2] <> 'tested1' then Halt(13); + if sarr[3] <> 'static3' then Halt(14); + + prepare; + test_openarray_slice(sarr); // must leave elements 2 and 3 intact + if sarr[0] <> 'tested0' then Halt(21); + if sarr[1] <> 'tested1' then Halt(22); + if sarr[2] <> 'static2' then Halt(23); + if sarr[3] <> 'static3' then Halt(24); + + prepare; + test3(sarr); // entire static array + if sarr[0] <> 'tested0' then Halt(31); + if sarr[1] <> 'tested1' then Halt(32); + if sarr[2] <> 'tested2' then Halt(33); + if sarr[3] <> 'tested3' then Halt(34); + + prepare; + test3(sarr[1..2]); // static array subrange + if sarr[0] <> 'static0' then Halt(41); + if sarr[1] <> 'tested0' then Halt(42); + if sarr[2] <> 'tested1' then Halt(43); + if sarr[3] <> 'static3' then Halt(44); + + prepare; + test3(slice(sarr,2)); // static array slice + if sarr[0] <> 'tested0' then Halt(51); + if sarr[1] <> 'tested1' then Halt(52); + if sarr[2] <> 'static2' then Halt(53); + if sarr[3] <> 'static3' then Halt(54); + + prepare; + test3(darr); // entire dynamic array + if darr[0] <> 'tested0' then Halt(61); + if darr[1] <> 'tested1' then Halt(62); + if darr[2] <> 'tested2' then Halt(63); + if darr[3] <> 'tested3' then Halt(64); + + prepare; + test3(darr[1..2]); // dynamic array subrange + if darr[0] <> 'dynamic0' then Halt(71); + if darr[1] <> 'tested0' then Halt(72); + if darr[2] <> 'tested1' then Halt(73); + if darr[3] <> 'dynamic3' then Halt(74); + + prepare; + test3(slice(darr,2)); // dynamic array slice + if darr[0] <> 'tested0' then Halt(81); + if darr[1] <> 'tested1' then Halt(82); + if darr[2] <> 'dynamic2' then Halt(83); + if darr[3] <> 'dynamic3' then Halt(84); + +end. diff --git a/tests/test/tclass13.pp b/tests/test/tclass13.pp index 6346dc8757..a1fdb8bbe3 100644 --- a/tests/test/tclass13.pp +++ b/tests/test/tclass13.pp @@ -15,8 +15,19 @@ type FTest: Integer; type TNode = class + FNode: TRootClass.TNode.TNode; end; en = (e1,e2); + TOtherNode = class + public + type + TNestedInOtherNode = class + ffield: longint; + end; + end; + TFinalNode = class + fx: TRootClass.TOtherNode.TNestedInOtherNode; + end; published property Test: Integer read FTest write FTest; end; @@ -36,6 +47,7 @@ begin Test1 := TNode.TNode.Create; if Test1.ClassName <> 'TRootClass.TNode.TNode' then halt(2); + Test1.FNode:=Test1; Test1.Free; end; diff --git a/tests/test/tclass13a.pp b/tests/test/tclass13a.pp new file mode 100644 index 0000000000..1a7a587e40 --- /dev/null +++ b/tests/test/tclass13a.pp @@ -0,0 +1,17 @@ +{ %norun } +{$mode delphi} + +type + tc = class + type + tnest = class + end; + end; + td = class(tc) + type + tnest = class(tc.tnest) + end; + end; + +begin +end. diff --git a/tests/test/tclass13b.pp b/tests/test/tclass13b.pp new file mode 100644 index 0000000000..6210bdb63a --- /dev/null +++ b/tests/test/tclass13b.pp @@ -0,0 +1,23 @@ +{ %norun } + +{$mode delphi} + +type + tc = class + type + tforward = class; + + tnested = class + type + tforward = class; + + tforward = class + end; + end; + + tforward = class + end; + end; + +begin +end. diff --git a/tests/test/tindex.pp b/tests/test/tindex.pp index ae5bb66214..c128b53ee3 100644 --- a/tests/test/tindex.pp +++ b/tests/test/tindex.pp @@ -46,12 +46,29 @@ begin writeln('indexbyte error 2 for (',i,',',j,',',k,')'); halt(2); end; + {same for length=-1} + if indexbyte(b[k+4],-1,0)<>index then + begin + writeln(indexbyte(b[k+4],-1,0),' <> ',index); + writeln('indexbyte error 2a for (',i,',',j,',',k,')'); + halt(22); + end; + if indexbyte(b[k+4],i,b[k+4+i-1])<>i-1 then begin writeln('indexbyte error 3 for (',i,',',j,',',k,')'); halt(3); end; + {same for length=-1} + if i<>0 then // previous test will be no-op when i=0 + if indexbyte(b[k+4],-1,b[k+4+i-1])<>i-1 then + begin + writeln('indexbyte error 3a for (',i,',',j,',',k,')'); + halt(23); + end; + + if (i<1) then index:=-1 else @@ -62,6 +79,16 @@ begin writeln('indexbyte error 4 for (',i,',',j,',',k,')'); halt(4); end; + {same for length=-1} + if i<>0 then // previous test will be no-op when i=0 + if indexbyte(b[k+4],-1,b[k+4+i shr 1])<>index then + begin + writeln(indexbyte(b[k+4],-1,b[k+4+i shr 1]),' <> ',index); + writeln('indexbyte error 4a for (',i,',',j,',',k,')'); + halt(24); + end; + + if (i=0) then index:=-1 else @@ -69,8 +96,15 @@ begin if indexbyte(b[k+4],i,b[k+4])<>index then begin writeln('indexbyte error 5 for (',i,',',j,',',k,')'); - halt(3); + halt(5); end; + {same for length=-1} + if i<>0 then + if indexbyte(b[k+4],-1,b[k+4])<>index then + begin + writeln('indexbyte error 5a for (',i,',',j,',',k,')'); + halt(25); + end; if indexword(b[k+4],i shr 1,0)<>-1 then diff --git a/tests/test/tsec1.pp b/tests/test/tsec1.pp new file mode 100644 index 0000000000..3c43b8319b --- /dev/null +++ b/tests/test/tsec1.pp @@ -0,0 +1,6 @@ +{ %target=embedded } +var + d : longint;section '.bss'; + +begin +end. diff --git a/tests/test/units/system/tmem.pp b/tests/test/units/system/tmem.pp index 3ef647419c..7abb55226d 100644 --- a/tests/test/units/system/tmem.pp +++ b/tests/test/units/system/tmem.pp @@ -16,9 +16,7 @@ var dst_arraybyte : array[1..MAX_TABLE] of byte; src_arraybyte : array[1..MAX_TABLE] of byte; dst_arrayword : array[1..MAX_TABLE] of word; - src_arrayword : array[1..MAX_TABLE] of word; dst_arraylongword : array[1..MAX_TABLE] of longword; - src_arratlongword : array[1..MAX_TABLE] of longword; i: integer; @@ -70,6 +68,8 @@ procedure test_fillchar; for i := 1 to MAX_TABLE do dst_arraybyte[i] := DEFAULT_VALUE; fillchar(dst_arraybyte, -1, FILL_VALUE); + for i := 1 to MAX_TABLE do + test(dst_arraybyte[i], DEFAULT_VALUE); writeln('Passed!'); end; @@ -103,7 +103,7 @@ begin test(dst_arraybyte[i], FILL_VALUE); writeln('Passed!'); { zero move count } - write('test move (zero count)...'); + write('testing move (zero count)...'); for i := 1 to MAX_TABLE do begin dst_arraybyte[i] := DEFAULT_VALUE; @@ -114,11 +114,75 @@ begin test(dst_arraybyte[i], DEFAULT_VALUE); writeln('Passed!'); { negative move count } - write('test move (negative count)...'); + write('testing move (negative count)...'); move(src_arraybyte,dst_arraybyte,-12); writeln('Passed!'); end; + +procedure test_move_large(size: longint); +var + src, dst: PLongInt; + i: LongInt; +begin + GetMem(src, size*sizeof(LongInt)); + GetMem(dst, size*sizeof(LongInt)); + write('testing move of ',size,' dwords ...'); + for i := 0 to size-1 do + begin + src[i] := i; + dst[i] := -1; + end; + move(src[0], dst[2], (size-4)*sizeof(LongInt)); + test(dst[0], -1); + test(dst[1], -1); + test(dst[size-1], -1); + test(dst[size-2], -1); + for i := 2 to size-3 do + test(dst[i], i-2); + writeln('Passed!'); + + // repeat with source and dest swapped (maybe move in opposite direction) + // current implementations detect that regions don't overlap and move forward, + // so this test is mostly useless. But it won't harm anyway. + write('testing move of ',size,' dwords, opposite direction...'); + for i := 0 to size-1 do + begin + dst[i] := i; + src[i] := -1; + end; + move(dst[0], src[2], (size-4)*sizeof(LongInt)); + test(src[0], -1); + test(src[1], -1); + test(src[size-1], -1); + test(src[size-2], -1); + for i := 2 to size-3 do + test(src[i], i-2); + writeln('Passed!'); + + write('testing move of ',size,' dwords, overlapping forward...'); + for i := 0 to size-1 do + src[i] := i; + move(src[0], src[100], (size-100)*sizeof(LongInt)); + for i := 0 to 99 do + test(src[i], i); + for i := 100 to size-101 do + test(src[i], i-100); + writeln('Passed!'); + + write('testing move of ',size,' dwords, overlapping backward...'); + for i := 0 to size-1 do + src[i] := i; + move(src[100], src[0], (size-100)*sizeof(LongInt)); + for i := 0 to size-101 do + test(src[i], i+100); + for i := size-100 to size-1 do + test(src[i], i); + writeln('Passed!'); + FreeMem(dst); + FreeMem(src); +end; + {$ifdef fpc} procedure test_fillword; var @@ -271,6 +335,8 @@ end; begin test_fillchar; test_move; + test_move_large(500); // 512 longints=2048 bytes + test_move_large(500000); {$ifdef fpc} test_fillword; test_filldword; diff --git a/tests/webtbs/tw16040.pp b/tests/webtbs/tw16040.pp index 3026b69ff5..de5a36f2cc 100644 --- a/tests/webtbs/tw16040.pp +++ b/tests/webtbs/tw16040.pp @@ -1,5 +1,5 @@ uses - dateutils; + sysutils,dateutils; var date1, date2: tdatetime; @@ -26,8 +26,6 @@ begin writeln(date1:0:12); halt(3); end; - - date1:=EncodeDateTime(2010,03,23,0,0,0,0); date2:=JulianDateToDateTime(2455278.50000); if date1<>date2 then @@ -50,4 +48,66 @@ begin halt(6); end; + date1:=EncodeDateTime(2011,03,26,19,15,30,555); + if IsInLeapYear(date1) then + begin + writeln('IsInLeapYear test fail'); + halt(7); + end; + if not IsPM(date1) then + begin + writeln('IsPM test fail'); + halt(8); + end; + if YearOf(date1) <> 2011 then + begin + writeln('YearOf test fail'); + halt(9); + end; + if MonthOf(date1) <> 3 then + begin + writeln('MonthOf test fail'); + halt(10); + end; + if DayOf(date1) <> 26 then + begin + writeln('DayOf test fail'); + halt(11); + end; + if (HourOf(date1) <> 19) or (HourOfTheDay(date1) <> 19) then + begin + writeln('HourOf test fail'); + halt(11); + end; + if (MinuteOf(date1) <> 15) or (MinuteOfTheHour(date1) <> 15) then + begin + writeln('MinuteOf test fail'); + halt(12); + end; + if (SecondOf(date1) <> 30) or (SecondOfTheMinute(date1) <> 30) then + begin + writeln('SecondOf test fail'); + halt(13); + end; + if (MilliSecondOf(date1) <> 555) or (MilliSecondOfTheSecond(date1) <> 555) then + begin + writeln('MilliSecondOf test fail'); + halt(14); + end; + if StartOfTheYear(date1) <> EncodeDate(2011, 1, 1) then + begin + writeln('StartOfTheYear test fail'); + halt(15); + end; + if EndOfTheYear(date1) <> EncodeDateTime(2011,12,31,23,59,59,999) then + begin + writeln('EndOfTheYear test fail'); + halt(16); + end; + if scandatetime('YYYY.MM.DD HH:NN:SS:ZZZ', '2011.03.29 16:46:56:777') <> + EncodeDateTime(2011,03,29,16,46,56,777) then + begin + writeln('scandatetime test fail'); + halt(17); + end; end. diff --git a/tests/webtbs/tw18567 b/tests/webtbs/tw18567.pp index b2018a88b8..b2018a88b8 100644 --- a/tests/webtbs/tw18567 +++ b/tests/webtbs/tw18567.pp diff --git a/tests/webtbs/tw18702.pp b/tests/webtbs/tw18702.pp new file mode 100644 index 0000000000..69a54be3bc --- /dev/null +++ b/tests/webtbs/tw18702.pp @@ -0,0 +1,38 @@ +program project1; + +{$mode objfpc}{$H+} +{$modeswitch nestedprocvars} + +type + TGetSQLTextProc = function() : string is nested; + +procedure TestSQLFieldType(AGetSQLTextProc: TGetSQLTextProc); +var + i : byte; + s: string; +begin + for i := 0 to 9 do + begin + s := AGetSQLTextProc(); + if s<>'hello' then + begin + writeln('Failed'); + halt(i+1); + end; + end; +end; + +procedure TestSQLClob; + + function GetSQLText() : string; + begin + result := 'hello'; + end; + +begin + TestSQLFieldType(@GetSQLText); +end; + +begin + TestSQLClob; +end. diff --git a/tests/webtbs/tw18859.pp b/tests/webtbs/tw18859.pp new file mode 100644 index 0000000000..f5d229d586 --- /dev/null +++ b/tests/webtbs/tw18859.pp @@ -0,0 +1,38 @@ +{ %OPT=-gh } +Program project1; + +{$mode objfpc} +{$h+} + +type + trec = record + s: string; + end; + +procedure test1(values: array of string); +begin + if paramcount = 0 then + values[0] := values[0] + '1' + else + values[0] := '1'; +end; + + +procedure test2(values: array of trec); +begin + if paramcount = 0 then + values[0].s := values[0].s + '1' + else + values[0].s := '1'; +end; + +var + tr: trec; + +begin + HaltOnNotReleased := True; + tr.s := 'test'; + uniquestring(tr.s); + test1([tr.s]); + test2([tr]); +end. |
