Revision: 76044
http://sourceforge.net/p/brlcad/code/76044
Author: starseeker
Date: 2020-06-06 17:20:58 +0000 (Sat, 06 Jun 2020)
Log Message:
-----------
Start setting up a test intended to build and run against the CAD libraries the
way an external project would (i.e. without using the compile-time definitions
or APIs.) Not turning on right now as it won't build...
Modified Paths:
--------------
brlcad/trunk/regress/CMakeLists.txt
brlcad/trunk/regress/rtwizard/regress-rtwiz.cmake.in
Added Paths:
-----------
brlcad/trunk/regress/user/
brlcad/trunk/regress/user/CMakeLists.txt
brlcad/trunk/regress/user/cad_user.c
brlcad/trunk/regress/user/regress-user.cmake.in
Modified: brlcad/trunk/regress/CMakeLists.txt
===================================================================
--- brlcad/trunk/regress/CMakeLists.txt 2020-06-06 17:10:58 UTC (rev 76043)
+++ brlcad/trunk/regress/CMakeLists.txt 2020-06-06 17:20:58 UTC (rev 76044)
@@ -55,6 +55,9 @@
# Repository check
add_subdirectory(repository)
+# Simulation of a 3rd party BRL-CAD library client code
+add_subdirectory(user)
+
if(SH_EXEC)
add_test(NAME regress-moss COMMAND ${SH_EXEC}
"${CMAKE_SOURCE_DIR}/regress/moss.sh" ${CMAKE_SOURCE_DIR})
Modified: brlcad/trunk/regress/rtwizard/regress-rtwiz.cmake.in
===================================================================
--- brlcad/trunk/regress/rtwizard/regress-rtwiz.cmake.in 2020-06-06
17:10:58 UTC (rev 76043)
+++ brlcad/trunk/regress/rtwizard/regress-rtwiz.cmake.in 2020-06-06
17:20:58 UTC (rev 76044)
@@ -32,7 +32,7 @@
endif (NOT EXISTS "${PIXCMP_EXEC}")
# Reconstruct the tree root from the EXEC path, and identify the input file
location
-string(REGEX_REPLACE "${BIN_DIR}$" "" RDIR "${BDIR}")
+string(REGEX REPLACE "${BIN_DIR}$" "" RDIR "${BDIR}")
set(SRCFILE "${RDIR}/${INPUTFILE}")
# Clean up in case we've run before
Added: brlcad/trunk/regress/user/CMakeLists.txt
===================================================================
--- brlcad/trunk/regress/user/CMakeLists.txt (rev 0)
+++ brlcad/trunk/regress/user/CMakeLists.txt 2020-06-06 17:20:58 UTC (rev
76044)
@@ -0,0 +1,40 @@
+# This program is intended to test the usability of BRL-CAD's libraries without
+# the internal compile-time APIs - i.e., to simulate what a BRL-CAD client code
+# might experience when trying to use the BRL-CAD libraries.
+
+# Due to the nature of this test, it should not see any of the defines used for
+# by BRL-CAD to enable compile-time API. We first clear any inherited include
+# directories or compile definitions:
+set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS "")
+set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")
+
+
+# NOTE - for the moment we are not overriding the compile flags (optimization,
+# warnings, etc.) from the parent build, although eventually we should probably
+# look into doing so... We want the strictness of those checks to apply to
+# this code as well, so long as they don't also contain anything that ties this
+# code to any internal, compile time behaviors or features.
+
+# We deliberately do not use any of the BRL-CAD wrapper macros, to avoid
automatic
+# addtiion of compile defintions or other magic specific to BRL-CAD's internal
build.
+add_executable(cad_user cad_user.c)
+target_link_libraries(cad_user libged)
+target_include_directories(cad_user PUBLIC
"${CMAKE_BINARY_DIR}/${INCLUDE_DIR}/brlcad")
+
+set_target_properties(lcheck PROPERTIES FOLDER "BRL-CAD Regression Tests/user")
+
+set(LOG_FILE "${CMAKE_CURRENT_BINARY_DIR}/regress-user.log")
+#BRLCAD_REGRESSION_TEST(regress-user "cad_user;moss.g" EXEC cad_user)
+DISTCLEAN(${LOG_FILE})
+
+CMAKEFILES(
+ CMakeLists.txt
+ regress-user.cmake.in
+ )
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
Property changes on: brlcad/trunk/regress/user/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/regress/user/cad_user.c
===================================================================
--- brlcad/trunk/regress/user/cad_user.c (rev 0)
+++ brlcad/trunk/regress/user/cad_user.c 2020-06-06 17:20:58 UTC (rev
76044)
@@ -0,0 +1,82 @@
+/* C A D _ U S E R . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2020 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file cad_user.c
+ *
+ * Code using BRL-CAD libraries that is intended to simulate an
+ * external user of an installed BRL-CAD, without using any compile-time
+ * features specific to the BRL-CAD build environment.
+ */
+
+#include <common.h>
+#include <brlcad_version.h>
+#include <bu.h>
+#include <ged.h>
+
+int
+main(int ac, char *av[]) {
+ struct ged *gedp;
+
+ /* Need this for bu_dir to work correctly */
+ bu_setprogname(av[0]);
+
+ if (ac != 2) {
+ printf("Usage: %s g_file\n", av[0]);
+ return 1;
+ }
+
+ if (!bu_file_exists(av[1], NULL)) {
+ printf("Error: %s does not exist\n", av[1]);
+ return 1;
+ }
+
+ gedp = ged_open("db", av[1], 0);
+
+ if (!gedp) {
+ bu_log("Error - could not open database %s\n", av[1]);
+ return 1;
+ }
+
+ const char *gcmd[3];
+ gcmd[0] = "search";
+ gcmd[1] = "/";
+
+ if (ged_search(gedp, 2, (const char **)gcmd) != GED_OK) {
+ goto user_test_fail;
+ }
+
+ ged_close(gedp);
+ BU_PUT(gedp, struct ged);
+ return 0;
+
+user_test_fail:
+ ged_close(gedp);
+ BU_PUT(gedp, struct ged);
+ return 1;
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Property changes on: brlcad/trunk/regress/user/cad_user.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/regress/user/regress-user.cmake.in
===================================================================
--- brlcad/trunk/regress/user/regress-user.cmake.in
(rev 0)
+++ brlcad/trunk/regress/user/regress-user.cmake.in 2020-06-06 17:20:58 UTC
(rev 76044)
@@ -0,0 +1,40 @@
+# Values set at CMake configure time
+set(BIN_DIR "@BIN_DIR@")
+set(DATA_DIR "@DATA_DIR@")
+set(LOGFILE "@LOG_FILE@")
+
+file(WRITE "${LOGFILE}" "Starting 3rd party user simulation run\n")
+
+# The executable location isn't know at CMake configure time, so it must be
+# passed in via the EXEC variable at runtime. De-quote it and assign it to the
+# appropriate variable.
+string(REPLACE "\\" "" USER_EXEC "${EXEC}")
+if (NOT EXISTS "${USER_EXEC}")
+ file(WRITE "${LOGFILE}" "cad_user not found at location \"${USER_EXEC}\" -
aborting\n")
+ message(FATAL_ERROR "Unable to find cad_user, aborting.\nSee ${LOGFILE} for
more details.")
+endif (NOT EXISTS "${USER_EXEC}")
+
+# Reconstruct the tree root from the EXEC path, and identify the input file
location
+get_filename_component(BDIR "${USER_EXEC}" DIRECTORY)
+string(REGEX REPLACE "${BIN_DIR}$" "" RDIR "${BDIR}")
+set(GFILE "${RDIR}/${DATA_DIR}/db/moss.g")
+
+# Runn the command
+file(APPEND "${LOGFILE}" "Running ${USER_EXEC} ${GFILE}:\n")
+execute_process(
+ COMMAND "${USER_EXEC}" "${GFILE}"
+ RESULT_VARIABLE user_result OUTPUT_VARIABLE user_log ERROR_VARIABLE user_log
+ )
+file(APPEND "${LOGFILE}" "${user_log}")
+if(user_result)
+ file(APPEND "${LOGFILE}" "Failure: ${user_result}")
+ message(FATAL_ERROR "3rd party user simulation run failed, aborting.\nSee
${LOGFILE} for more details.")
+endif(user_result)
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
+
Property changes on: brlcad/trunk/regress/user/regress-user.cmake.in
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits