Skip to content

Commit

Permalink
Feature #382, Feature #367, Support #303
Browse files Browse the repository at this point in the history
  • Loading branch information
endurox-dev committed Feb 2, 2019
1 parent b32e440 commit 40714d7
Show file tree
Hide file tree
Showing 32 changed files with 1,936 additions and 109 deletions.
2 changes: 2 additions & 0 deletions atmitest/CMakeLists.txt
Expand Up @@ -110,6 +110,8 @@ ENDIF()

add_subdirectory (test059_pq)
add_subdirectory (test060_ndxdfork)
add_subdirectory (test062_memlimits)
add_subdirectory (test063_cpmrange)

################################################################################
# Master test case driver
Expand Down
16 changes: 16 additions & 0 deletions atmitest/atmiunit1.c
Expand Up @@ -491,6 +491,20 @@ Ensure(test061_ndxddup)
assert_equal(ret, EXSUCCEED);
}

Ensure(test062_memlimits)
{
int ret;
ret=system_dbg("test062_memlimits/run.sh");
assert_equal(ret, EXSUCCEED);
}

Ensure(test063_cpmrange)
{
int ret;
ret=system_dbg("test063_cpmrange/run.sh");
assert_equal(ret, EXSUCCEED);
}

TestSuite *atmi_test_all(void)
{
TestSuite *suite = create_test_suite();
Expand Down Expand Up @@ -588,6 +602,8 @@ TestSuite *atmi_test_all(void)
add_test(suite, test059_pq);
add_test(suite, test060_ndxdfork);
add_test(suite, test061_ndxddup);
add_test(suite, test062_memlimits);
add_test(suite, test063_cpmrange);

return suite;
}
Expand Down
67 changes: 67 additions & 0 deletions atmitest/test062_memlimits/CMakeLists.txt
@@ -0,0 +1,67 @@
##
## @brief Test memory limit restarts - server
##
## @file atmisv62.c
##
## -----------------------------------------------------------------------------
## Enduro/X Middleware Platform for Distributed Transaction Processing
## Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
## Copyright (C) 2017-2018, Mavimax, Ltd. All Rights Reserved.
## This software is released under one of the following licenses:
## AGPL or Mavimax's license for commercial use.
## -----------------------------------------------------------------------------
## AGPL license:
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU Affero General Public License, version 3 as published
## by the Free Software Foundation;
##
## This program 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 Affero General Public License, version 3
## for more details.
##
## You should have received a copy of the GNU Affero General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
## -----------------------------------------------------------------------------
## A commercial use license is available from Mavimax, Ltd
## contact@mavimax.com
## -----------------------------------------------------------------------------
##

cmake_minimum_required(VERSION 2.8)

# Make sure the compiler can find include files from UBF library
include_directories (${ENDUROX_SOURCE_DIR}/libubf
${ENDUROX_SOURCE_DIR}/include
${ENDUROX_SOURCE_DIR}/libnstd
${ENDUROX_SOURCE_DIR}/ubftest)


# Add debug options
# By default if RELEASE_BUILD is not defined, then we run in debug!
IF ($ENV{RELEASE_BUILD})
# do nothing
ELSE ($ENV{RELEASE_BUILD})
ADD_DEFINITIONS("-D NDRX_DEBUG")
ENDIF ($ENV{RELEASE_BUILD})

# Make sure the linker can find the UBF library once it is built.
link_directories (${ENDUROX_BINARY_DIR}/libubf)

############################# Test - executables ###############################
add_executable (atmi.sv62 atmisv62.c ../../libatmisrv/rawmain_integra.c)
add_executable (atmiclt62 atmiclt62.c)
################################################################################
############################# Test - executables ###############################
# Link the executable to the ATMI library & others...
target_link_libraries (atmi.sv62 atmisrvinteg atmi ubf nstd m pthread ${RT_LIB})
target_link_libraries (atmiclt62 atmiclt atmi ubf nstd m pthread ${RT_LIB})

set_target_properties(atmi.sv62 PROPERTIES LINK_FLAGS "$ENV{MYLDFLAGS}")
set_target_properties(atmiclt62 PROPERTIES LINK_FLAGS "$ENV{MYLDFLAGS}")
################################################################################

# vim: set ts=4 sw=4 et smartindent:
145 changes: 145 additions & 0 deletions atmitest/test062_memlimits/atmiclt62.c
@@ -0,0 +1,145 @@
/**
* @brief Test memory limit restarts - client
*
* @file atmiclt62.c
*/
/* -----------------------------------------------------------------------------
* Enduro/X Middleware Platform for Distributed Transaction Processing
* Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
* Copyright (C) 2017-2018, Mavimax, Ltd. All Rights Reserved.
* This software is released under one of the following licenses:
* AGPL or Mavimax's license for commercial use.
* -----------------------------------------------------------------------------
* AGPL license:
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License, version 3 as published
* by the Free Software Foundation;
*
* This program 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 Affero General Public License, version 3
* for more details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* -----------------------------------------------------------------------------
* A commercial use license is available from Mavimax, Ltd
* contact@mavimax.com
* -----------------------------------------------------------------------------
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>

#include <atmi.h>
#include <ubf.h>
#include <ndebug.h>
#include <test.fd.h>
#include <ndrstandard.h>
#include <nstopwatch.h>
#include <fcntl.h>
#include <unistd.h>
#include <nstdutil.h>
#include "test62.h"
/*---------------------------Externs------------------------------------*/
/*---------------------------Macros-------------------------------------*/
/*---------------------------Enums--------------------------------------*/
/*---------------------------Typedefs-----------------------------------*/
/*---------------------------Globals------------------------------------*/
/*---------------------------Statics------------------------------------*/
/*---------------------------Prototypes---------------------------------*/

/**
* Do the test call to the server
*/
int main(int argc, char** argv)
{
UBFH *p_ub = (UBFH *)tpalloc("UBF", NULL, 56000);
long rsplen;
int ret=EXSUCCEED;
static char *buf = NULL;
int i;

if (argc < 2)
{
NDRX_LOG(log_error, "Usage: %s srvrss|srvvsz|cltrss|cltvsz", argv[0]);
EXFAIL_OUT(ret);
}

/* server tests */
if (0==strcmp("srvrss", argv[1]))
{
if (EXFAIL == tpcall("RSSALLOC", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
{
NDRX_LOG(log_error, "RSSALLOC failed: %s", tpstrerror(tperrno));
ret=EXFAIL;
goto out;
}
}
else if (0==strcmp("srvvsz", argv[1]))
{
if (EXFAIL == tpcall("VSZALLOC", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
{
NDRX_LOG(log_error, "VSZALLOC failed: %s", tpstrerror(tperrno));
ret=EXFAIL;
goto out;
}
}

/* client tests: */
else if (0==strcmp("cltrss", argv[1]))
{
/* let system to pick up the pid */
sleep(20);
if (NULL==buf)
{
buf = NDRX_MALLOC(RSS_BLOCK);

if (NULL==buf)
{
NDRX_LOG(log_error, "TESTERROR ! Failed to alloc %d bytes: %s",
RSS_BLOCK, strerror(errno));
EXFAIL_OUT(ret);
}
}

/* store some values there and trick out the kernel not to
* figure out our strategy */
for (i=0; i<RSS_BLOCK; i++)
{
buf[i] = i/3;
}
sleep(9999);
}
else if (0==strcmp("cltvsz", argv[1]))
{
/* let system to pick up the pid */
sleep(20);
buf = NDRX_MALLOC(VSZ_BLOCK);
if (NULL==buf)
{
NDRX_LOG(log_error, "TESTERROR ! Failed to alloc %d bytes: %s",
VSZ_BLOCK, strerror(errno));
EXFAIL_OUT(ret);
}
sleep(9999);
}
else
{
NDRX_LOG(log_error, "Invalid test case: [%s]", argv[1]);
EXFAIL_OUT(ret);
}
out:
tpterm();
fprintf(stderr, "Exit with %d\n", ret);

return ret;
}

/* vim: set ts=4 sw=4 et smartindent: */

0 comments on commit 40714d7

Please sign in to comment.