Skip to content

Commit

Permalink
another test, long loop for long tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusmm committed Feb 18, 2019
1 parent 5ad8ced commit 24a27f3
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/C/long_test1/Makefile
@@ -0,0 +1,52 @@
TARGET = long_test1

TARGET_ARCH=riscv32

CC = riscv32-unknown-elf-gcc

# compiling flags here
CFLAGS = -Wall -I. -O0 -static -march=rv32imac -mabi=ilp32 --specs=nosys.specs


LINKER = riscv32-unknown-linux-gnu-gcc
# linking flags here
LDFLAGS = -I. --entry main -L/opt/riscv/riscv32-unknown-elf/lib/ -T ld_script.ld
LIBS = $(EXTRA_LIBS)


# change these to proper directories where each file should be
SRCDIR = ./
OBJDIR = .
BINDIR = ./
INCDIR = -I.
LIBDIR = -L.


SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(INCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)

rm = rm -f


$(BINDIR)/$(TARGET): $(OBJECTS)
# $(LINKER) $(OBJECTS) $(LDFLAGS) $(LIBS) $(LIBDIR) -o $@
riscv32-unknown-linux-gnu-objdump -d $< > dump
objcopy -Oihex $< $(TARGET).hex
# @echo "Linking complete!"

$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@echo "Compiling "$<" ..."
# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
$(CC) $(CFLAGS) $(INCDIR) $< -o $@
@echo "Done!"

.PHONY: clean
clean:
@$(rm) $(OBJECTS) *.hex dump
@echo "Cleanup complete!"

.PHONY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@echo "Executable removed!"
68 changes: 68 additions & 0 deletions tests/C/long_test1/long_test1.c
@@ -0,0 +1,68 @@
#include <string.h>
#include <stdio.h>

#define TRACE (*(unsigned char *)0x40000000)
int _read(int file, char* ptr, int len) {
return 0;
}

int _close(int fd){
return 0;
}

int _fstat_r(int fd) {
return 0;
}

int _lseek_r(struct _reent *ptr, FILE *fp, long offset, int whence){
return 0;
}

int _isatty_r(struct _reent *ptr, int fd) {
return 0;
}

int _write(int file, const char *ptr, int len) {
int x;

for (x = 0; x < len; x++) {
TRACE = *ptr++;
}

return (len);
}

int main(void) {

int aux[5] = {0, 1, 2, 3, 4};
int aux2[5];
int counter = 0;

printf("Long test Start\n");


while(1) {

memcpy(aux2, aux, sizeof(int)*5);
counter++;

for(int i = 0; i < 5; i++) {
if (aux[i] != aux2[i]) {
printf("ERROR %d\n", i);
asm volatile ("ecall");
}
}

if (counter > 10000) {
printf(".\n");
counter = 0;
}
}
printf("OK!\n");



asm volatile ("ecall");

return 0;
}

0 comments on commit 24a27f3

Please sign in to comment.