mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-03 21:09:12 +00:00 
			
		
		
		
	Added required structure to implement unit tests
Added modifications inside the main Makefile to refers the unit test Makefile. Added separated Makefile only for compiling unit tests. Added simple example of unit test. Signed-off-by: Charles Oliveira <18oliveira.charles@gmail.com> Signed-off-by: Pablo Alejandro <pabloabur@usp.br> Signed-off-by: Rodrigo Siqueira <siqueira@ime.usp.br>
This commit is contained in:
		
							parent
							
								
									a44cc7a3d1
								
							
						
					
					
						commit
						e0152319f5
					
				
					 5 changed files with 73 additions and 0 deletions
				
			
		
							
								
								
									
										28
									
								
								tests/unit/Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tests/unit/Makefile
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
GTESTFLAG := -lgtest -lgtest_main
 | 
			
		||||
RPATH := -Wl,-rpath
 | 
			
		||||
EXTRAFLAGS := -lyosys
 | 
			
		||||
 | 
			
		||||
ALLTESTFILE := $(wildcard ./**/*Test.cc)
 | 
			
		||||
OBJTEST := objtest
 | 
			
		||||
BINTEST := bintest
 | 
			
		||||
 | 
			
		||||
all: prepare $(ALLTESTFILE:%Test.cc=%Test.o)
 | 
			
		||||
 | 
			
		||||
%Test.o: %Test.cc
 | 
			
		||||
	$(CXX) -o $(OBJTEST)/$(notdir $@) -c -I$(ROOTPATH) $(CPPFLAGS) $(CXXFLAGS) $<
 | 
			
		||||
	$(CXX) -L$(ROOTPATH) $(RPATH)=$(ROOTPATH) -o \
 | 
			
		||||
		$(BINTEST)/$(basename $(notdir $@)) $(OBJTEST)/$(notdir $@) $(LDLIBS) \
 | 
			
		||||
		$(GTESTFLAG) $(EXTRAFLAGS)
 | 
			
		||||
	
 | 
			
		||||
.PHONY: prepare run-tests clean
 | 
			
		||||
 | 
			
		||||
run-tests:
 | 
			
		||||
	$(CURDIR)/$(BINTEST)/*
 | 
			
		||||
 | 
			
		||||
prepare:
 | 
			
		||||
	mkdir -p $(OBJTEST)
 | 
			
		||||
	mkdir -p $(BINTEST)
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	rm -rf $(OBJTEST)
 | 
			
		||||
	rm -rf $(BINTEST)
 | 
			
		||||
							
								
								
									
										14
									
								
								tests/unit/kernel/logTest.cc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tests/unit/kernel/logTest.cc
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
#include <gtest/gtest.h>
 | 
			
		||||
 | 
			
		||||
#include "kernel/yosys.h"
 | 
			
		||||
#include "kernel/log.h"
 | 
			
		||||
 | 
			
		||||
YOSYS_NAMESPACE_BEGIN
 | 
			
		||||
 | 
			
		||||
TEST(KernelLogTest, logvValidValues)
 | 
			
		||||
{
 | 
			
		||||
	//TODO: Implement log test
 | 
			
		||||
	EXPECT_EQ(7, 7);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
YOSYS_NAMESPACE_END
 | 
			
		||||
							
								
								
									
										14
									
								
								tests/unit/kernel/rtlilTest.cc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tests/unit/kernel/rtlilTest.cc
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,14 @@
 | 
			
		|||
#include <gtest/gtest.h>
 | 
			
		||||
 | 
			
		||||
#include "kernel/yosys.h"
 | 
			
		||||
#include "kernel/rtlil.h"
 | 
			
		||||
 | 
			
		||||
YOSYS_NAMESPACE_BEGIN
 | 
			
		||||
 | 
			
		||||
TEST(KernelRtlilTest, getReferenceValid)
 | 
			
		||||
{
 | 
			
		||||
	//TODO: Implement rtlil test
 | 
			
		||||
	EXPECT_EQ(33, 33);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
YOSYS_NAMESPACE_END
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue