Skip to content

Commit

Permalink
rework zlib cmake logic, add smoke tests, update build_ascent to use …
Browse files Browse the repository at this point in the history
…zlib 1.3
  • Loading branch information
cyrush committed Nov 6, 2023
1 parent 11b731d commit bdd0037
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 19 deletions.
2 changes: 1 addition & 1 deletion scripts/build_ascent/build_ascent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fi
################
# Zlib
################
zlib_version=1.2.13
zlib_version=1.3
zlib_src_dir=$(ospath ${root_dir}/zlib-${zlib_version})
zlib_build_dir=$(ospath ${root_dir}/build/zlib-${zlib_version}/)
zlib_install_dir=$(ospath ${root_dir}/install/zlib-${zlib_version}/)
Expand Down
18 changes: 0 additions & 18 deletions src/cmake/thirdparty/SetupMFEM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,6 @@ else()
set(MFEM_CALIPER_ENABLED TRUE)
endif()


# next check for ZLIB_DIR
# (spack builds of mfem now depend on zlib, and that is not propgating)
#
# TODO: Decide if we want to be strict about this
# if(NOT ZLIB_DIR)
# MESSAGE(FATAL_ERROR "MFEM support needs explicit ZLIB_DIR")
# endif()
#

if(ZLIB_DIR)
set(ZLIB_ROOT ${ZLIB_DIR})
find_package(ZLIB REQUIRED)
endif()

#
# Add ZLIB to the mfem_tpl_lnk_flags
#
if(ZLIB_FOUND)
list(APPEND mfem_tpl_lnk_flags ${ZLIB_LIBRARIES})
endif()
Expand Down
11 changes: 11 additions & 0 deletions src/tests/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ if(HIP_FOUND)
list(APPEND smoke_device_deps blt_hip)
endif()

set(conduit_smoke_deps conduit::conduit)

if(ZLIB_FOUND)
message(STATUS "Adding zlib smoke test")
list(APPEND conduit_smoke_deps ${ZLIB_LIBRARIES})
add_cpp_test(TEST t_zlib_smoke DEPENDS_ON ${ZLIB_LIBRARIES})
endif()

message(STATUS "Adding conduit smoke test")
add_cpp_test(TEST t_conduit_smoke DEPENDS_ON ${conduit_smoke_deps})

if(CALIPER_FOUND)
message(STATUS "Adding caliper smoke test")
add_cpp_test(TEST t_caliper_smoke DEPENDS_ON caliper)
Expand Down
30 changes: 30 additions & 0 deletions src/tests/thirdparty/t_conduit_smoke.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
// other details. No copyright assignment is required to contribute to Ascent.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

//-----------------------------------------------------------------------------
///
/// file: t_conduit_smoke.cpp
///
//-----------------------------------------------------------------------------

#include "gtest/gtest.h"
#include "conduit.hpp"
#include "conduit_relay.hpp"
#include "conduit_blueprint.hpp"


//-----------------------------------------------------------------------------
TEST(conduit_smoke, conduit_about)
{
conduit::Node about;
conduit::about(about["conduit"]);
conduit::relay::about(about["conduit/relay"]);
conduit::relay::io::about(about["conduit/relay/io"]);
conduit::blueprint::about(about["conduit/blueprint"]);

std::cout << about.to_yaml() << std::endl;
}

85 changes: 85 additions & 0 deletions src/tests/thirdparty/t_zlib_smoke.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
// other details. No copyright assignment is required to contribute to Ascent.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

//-----------------------------------------------------------------------------
///
/// file: t_zlib_smoke.cpp
///
//-----------------------------------------------------------------------------

#include "gtest/gtest.h"
#include "zlib.h"

//-----------------------------------------------------------------------------
TEST(zlib_smoke, zlib_basic)
{
Bytef compress_dest[32];
Bytef compress_src[32];
Bytef uncompress_dest[64];

uLongf compress_dest_len = 32;
uLongf compress_src_len = 32;
uLongf uncompress_dest_len = 32;

for(int i=0;i<32;i++)
{
compress_dest[i] = 0;
uncompress_dest[i] = 0;
// some pattern
compress_dest[i] = i > 4 && i < 28;
}

int compress_res = compress(compress_dest,
&compress_dest_len,
compress_src,
compress_src_len);

EXPECT_EQ(Z_OK,compress_res);


int uncompress_res = uncompress(uncompress_dest,
&uncompress_dest_len,
compress_dest,
compress_dest_len);
EXPECT_EQ(Z_OK,uncompress_res);

for(int i=0;i<32;i++)
{
EXPECT_EQ(compress_src[i],uncompress_dest[i]);
}

//
// EXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen));
// /*
// Compresses the source buffer into the destination buffer. sourceLen is
// the byte length of the source buffer. Upon entry, destLen is the total size
// of the destination buffer, which must be at least the value returned by
// compressBound(sourceLen). Upon exit, destLen is the actual size of the
// compressed buffer.
//
// compress returns Z_OK if success, Z_MEM_ERROR if there was not
// enough memory, Z_BUF_ERROR if there was not enough room in the output
// buffer.
// */
//
// ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen));
// /*
// Decompresses the source buffer into the destination buffer. sourceLen is
// the byte length of the source buffer. Upon entry, destLen is the total size
// of the destination buffer, which must be large enough to hold the entire
// uncompressed data. (The size of the uncompressed data must have been saved
// previously by the compressor and transmitted to the decompressor by some
// mechanism outside the scope of this compression library.) Upon exit, destLen
// is the actual size of the uncompressed buffer.
//
// uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
// enough memory, Z_BUF_ERROR if there was not enough room in the output
// buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
// the case where there is not enough room, uncompress() will fill the output
// buffer with the uncompressed data up to that point.
// */
}

0 comments on commit bdd0037

Please sign in to comment.