-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read external data for test and extensions #324
Comments
add_pfunit_ctest(mytests TEST_SOURCES a.F90 b.F90 ... LINK_LIBRARIES /usr/lib/liblapack.a) Or you could separately provide a path (unfortunately must be the following order: add_pfunit_ctest(mytests TEST_SOURCES a.F90 b.F90 ... LINK_LIBRARIES lapack)
target_link_directories(mytests PRIVATE /usr/lib)
|
Thank you, I'm going to try to implement the solution for my first point. For the second point, yes I want that Fortran to read a CSV file that contains all the data to make the comparisons in the assertion test. I have tried in different ways but the result is that reads nothing. |
Are you asking how to write Fortran that reads a CSV file? It is difficult to anticipate what your exact issue is without more details. But one likely possibility is that the unit tests are running in your cmake "binary" directory, but your CSV file is in your "source" directory and is therefore not being found. I have a similar pattern in my examples in another project and use the following CMake command: FILE (COPY simple.yaml DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) Hope this helps. |
Excuse me for the lack of detail, I have tried to implement your lines and reviewed the documentation examples but still without success. Then following I write you in detail what I implemented, the files, and the error messages. I hope all be more clear and thank you for your previous answers. With respect to the question of the CVS file, I'm following the trivial example, then I have all the files in one folder. There are 4 files: the file to test (a fortran77 file), the .pf file where there are the below lines to import all the input information for the tests, the CMakeList.txt, and the build_with_cmake_and_run.x file. The location of the folder is Code_PPP/1_Test_tensor_op In the .pf files I'm running the following lines to load the information of the CSV file called diadic2D.csv and save the information in the variable import1 (This works without problems in fortran77 or Fortran90), when I print the content of import1 there is nothing.
I tried to run your line but I'm still confused and only get errors (what does it mean FILE, copy, destination). Could you please indicate to me if the line(s) go in the CMakeLists.txt or build_with_cmake_and_run.x file. With respect to my first question about the compilation with -llpack, when I compile my file I use "gfortran test tensor ope.for -llapack". Following your answer, I implemented the following lines in the file CMakeLists.txt and then I obtain two errors add_pfunit_ctest(my_test_tensor_llpack CMake Error at //home/william/pFUnit/include/add_pfunit_ctest.cmake:121 (target_link_libraries): CMake Error at //home/william/pFUnit/include/add_pfunit_ctest.cmake:121 (target_link_libraries): When I run the test this is the message that I get If I run the lines according to the first option, see below, there is not a detailed error add_pfunit_ctest (my_test_tensor_llpack #Name of the created executable Again thank you for your help |
OK - thank you for the extra details. Regarding the linkage to external libraries, I'll try to set something similar up on my end. These days I'm in a "pure" cmake world and such linkage issues are usually solved through transitive dependencies of the code to be tested. I.e., I don't usually need to bring in external libraries for just the tests. But it should be possible - need to replicate and see if the macro should be fixed or if I just botched the directions. Also, note that I'm nominally on vacation this week. Did a bit of work this morning because a I had an important meeting to attend. I may not be able to get back to this issue until next week. Cheers. |
Hello, please could please give more advice taking into consideration my last post. Actually, I write it again because It was disordered. For the question 2, In this question, I wonder if I'm making the wrong question because I'm taking the wrong way. Maybe you can indicate to me how is performed for example a series of 1000 tests, where I have in another file the test data of the 1000 test or if my idea of read the csv file is right and where could be the problem, I don't get any error message, I only see the problem when I add a line, again in the pf file, to print the information. For the question 1
I'm using the function dgetrf of the package LAPACK of fortran http://www.netlib.org/lapack/ I implemented your first alternative with the following lines add_pfunit_ctest (my_test_tensor_llpack and when run the test this is the message [ 10%] Building Fortran object CMakeFiles/sut.dir/tensor_ope_module.for.o When I implement your second alternative according to the following lines add_pfunit_ctest(my_test_tensor_llpack CMake Error at //home/william/pFUnit/include/add_pfunit_ctest.cmake:121 (target_link_libraries): CMake Error at //home/william/pFUnit/include/add_pfunit_ctest.cmake:121 (target_link_libraries): |
For Question 2, I'm not sure that I am any closer to understanding your question/issue. Q: Are you trying to test the code that reads this file of data? Or are does the file contain a set of parameters for which you want to run the same test logic many times but just with different values? These are very different, but I'm still not sure which you meant. For now I'm going to assume the latter: that you want to run the same test logic across multiple parameters. One way to accomplish this is with a ParameterizedTest. These are a bit more trouble to set up, but are intended to reuse the same test procedure multiple times but with different data. The data in your file could be read in the procedure that "generates" the parameter values for the tests. The error about not finding add_pfunit_ctest (my_test_tensor_llpack
TEST_SOURCES ${test_srcs}
OTHER_SOURCES a.F90 b.F90
LINK_LIBRARIES /usr/lib/x86_64-linux-gnu/liblapack.a
) In your second attempt, the add_pfunit_ctest(my_test_tensor_llpack
TEST_SOURCES ${test_srcs}
a.F90 b.F90 ...
LINK_LIBRARIES lapack
)
target_link_directories(my_test_tensor_llpack PRIVATE /usr/lib/x86_64-linux-gnu) |
Thank you for your last post, for question 2, without still implementing the ParameterizedTest, finally, I found that using the configuration of the trivial example, in the compilation, in the build folder is copied an empty version of my CVS file. Therefore, an empty file is read. In the end, if I copy the CVS file and run the executable I can evaluate the test that don't use the llapackage. I hope to have more time to implement in the future the parameterizedTest. For the question 1, I implemented both suggested solutions but still, it is presented errors. I copy the complete code of the Cmakelist ussing the first alternative, maybe there is another thing that I'm not defining correctly. find_package(/home/william/pFUnit/build/PFUNIT REQUIRED) #FILE() add_library (sut set (test_srcs test_tensor_mod.pf) f add_pfunit_ctest (my_test_tensor_llpack The error message is -- The Fortran compiler identification is GNU 9.3.0
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h CMake Error at //home/william/pFUnit/include/add_pfunit_ctest.cmake:77 (add_executable): CMake Generate step failed. Build files cannot be regenerated correctly. When I implemented the second alternative add_pfunit_ctest(my_test_tensor_llpack It is obtained one of the errors of the previous post. (And I tried to do the same change OTHER_SOURCES a.F90 b.F90 ... , but then the same error than the first alternative is obtained. -- The Fortran compiler identification is GNU 9.3.0 |
Again - apologies for the slow response. I'll try to be responsive this week so we can get something working for you. A complete reproducer would be useful here. CMake is telling you that it cannot find the source file I also see that in both attempts you have elipses ( In the 2nd approach, I also note that you don't have the OTHER_SOURCES argument indicator in your If at all possible, I recommend composing a small case that you cannot get to work. I should then be able to fix up the necessary cmake logic and get it back to you. |
Hello, I'm learning to use pFUnit and at this moment have two issues, I'm not used with Cmake files then it is not easy to deduce the answer
Thank you very much for your help
The text was updated successfully, but these errors were encountered: