Skip to content

Commit

Permalink
os400: build test servers
Browse files Browse the repository at this point in the history
Also fix a non-compliant main prototype in disabled.c.

Closes #11547
  • Loading branch information
monnerat authored and bagder committed Aug 30, 2023
1 parent 36d656f commit aafe43a
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 72 deletions.
7 changes: 5 additions & 2 deletions packages/OS400/initscript.sh
Expand Up @@ -185,8 +185,9 @@ make_module()
echo "#line 1" >> __tmpsrcf.c
cat "${2}" >> __tmpsrcf.c
CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
# CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
CMD="${CMD} SYSIFCOPT(*IFS64IO *ASYNCSIGNAL)"
# CMD="${CMD} OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
CMD="${CMD} OPTION(*INCDIRFIRST)"
CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
CMD="${CMD} INCDIR('${QADRTDIR}/include'"
CMD="${CMD} '${TOPDIR}/include/curl' '${TOPDIR}/include' '${SRCDIR}'"
Expand Down Expand Up @@ -265,6 +266,7 @@ versioned_copy()
# The `sed' statement works as follows:
# - Join \nl-separated lines.
# - Retain only lines that begins with "identifier =".
# - Replace @...@ sustitutions by shell variable references.
# - Turn these lines into shell variable assignments.

get_make_vars()
Expand All @@ -277,6 +279,7 @@ get_make_vars()
-e 'b begin' \
-e '}' \
-e '/^[A-Za-z_][A-Za-z0-9_]*[[:space:]]*=/!d' \
-e 's/@\\([A-Za-z0-9_]*\\)@/${\\1}/g' \
-e 's/[[:space:]]*=[[:space:]]*/=/' \
-e 's/=\\(.*[^[:space:]]\\)[[:space:]]*$/=\\"\\1\\"/' \
-e 's/\\\$(\\([^)]*\\))/\${\\1}/g' \
Expand Down
162 changes: 93 additions & 69 deletions packages/OS400/make-tests.sh
Expand Up @@ -32,90 +32,114 @@ SCRIPTDIR=`dirname "${0}"`
cd "${TOPDIR}/tests"


# tests directory not implemented yet.
# Build programs in a directory.

build_all_programs()

# Process the libtest subdirectory.
{
# Compile all programs.
# The list is found in variable "noinst_PROGRAMS"

cd libtest
INCLUDES="'`pwd`' '${TOPDIR}/lib' '${TOPDIR}/src'"
MODS="${1}"
SRVPGMS="${2}"

# Get definitions from the Makefile.inc file.
for PGM in ${noinst_PROGRAMS}
do DB2PGM=`db2_name "${PGM}"`
PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"

get_make_vars Makefile.inc
# Extract preprocessor symbol definitions from
# compilation options for the program.

# Special case: redefine chkhostname compilation parameters.
PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`"
PGMDFNS=

chkhostname_SOURCES=chkhostname.c
chkhostname_LDADD=curl_gethostname.o
for FLAG in ${PGMCFLAGS}
do case "${FLAG}" in
-D?*) DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
PGMDFNS="${PGMDFNS} '${DEFINE}'"
;;
esac
done

# Compile all programs.
# The list is found in variable "noinst_PROGRAMS"
# Compile all C sources for the program into modules.

PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`"
LINK=
MODULES=

for SOURCE in ${PGMSOURCES}
do case "${SOURCE}" in
*.c) # Special processing for libxxx.c files:
# their module name is determined
# by the target PROGRAM name.

case "${SOURCE}" in
lib*.c) MODULE="${DB2PGM}"
;;
*) MODULE=`db2_name "${SOURCE}"`
;;
esac

# If source is in a sibling directory,
# prefix module name with 'X'.

case "${SOURCE}" in
../*) MODULE=`db2_name "X${MODULE}"`
;;
esac

make_module "${MODULE}" "${SOURCE}" "${PGMDFNS}"
if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
then LINK=yes
fi
;;
esac
done

INCLUDES="'${TOPDIR}/tests/libtest' '${TOPDIR}/lib'"
# Link program if needed.

if [ "${LINK}" ]
then PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`"
for ARG in ${PGMLDADD}
do case "${ARG}" in
-*) ;; # Ignore non-module.
*) MODULES="${MODULES} "`db2_name "${ARG}"`
;;
esac
done
MODULES="`echo \"${MODULES}\" |
sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)"
CMD="${CMD} MODULE(${MODULES} ${MODS})"
CMD="${CMD} BNDSRVPGM(${SRVPGMS} QADRTTS)"
CMD="${CMD} TGTRLS(${TGTRLS})"
CLcommand "${CMD}"
fi
done
}

for PGM in ${noinst_PROGRAMS}
do DB2PGM=`db2_name "${PGM}"`
PGMIFSNAME="${LIBIFSNAME}/${DB2PGM}.PGM"

# Extract preprocessor symbol definitions from compilation
# options for the program.
# Build programs in the server directory.

PGMCFLAGS="`eval echo \"\\${${PGM}_CFLAGS}\"`"
PGMDEFINES=
(
cd server
get_make_vars Makefile.inc
build_all_programs "${TARGETLIB}/OS400SYS"
)

for FLAG in ${PGMCFLAGS}
do case "${FLAG}" in
-D?*) DEFINE="`echo \"${FLAG}\" | sed 's/^..//'`"
PGMDEFINES="${PGMDEFINES} '${DEFINE}'"
;;
esac
done

# Compile all C sources for the program into modules.
# Build all programs in the libtest subdirectory.

PGMSOURCES="`eval echo \"\\${${PGM}_SOURCES}\"`"
LINK=
MODULES=
(
cd libtest
get_make_vars Makefile.inc

for SOURCE in ${PGMSOURCES}
do case "${SOURCE}" in
*.c) # Special processing for libxxx.c files: their
# module name is determined by the target
# PROGRAM name.
# Special case: redefine chkhostname compilation parameters.

case "${SOURCE}" in
lib*.c) MODULE="${DB2PGM}"
;;
*) MODULE=`db2_name "${SOURCE}"`
;;
esac

make_module "${MODULE}" "${SOURCE}" "${PGMDEFINES}"
if action_needed "${PGMIFSNAME}" "${MODIFSNAME}"
then LINK=yes
fi
;;
esac
done
chkhostname_SOURCES=chkhostname.c
chkhostname_LDADD=curl_gethostname.o

# Link program if needed.

if [ "${LINK}" ]
then PGMLDADD="`eval echo \"\\${${PGM}_LDADD}\"`"
for LDARG in ${PGMLDADD}
do case "${LDARG}" in
-*) ;; # Ignore non-module.
*) MODULES="${MODULES} "`db2_name "${LDARG}"`
;;
esac
done
MODULES="`echo \"${MODULES}\" |
sed \"s/[^ ][^ ]*/${TARGETLIB}\/&/g\"`"
CMD="CRTPGM PGM(${TARGETLIB}/${DB2PGM})"
CMD="${CMD} ENTMOD(${TARGETLIB}/CURLMAIN)"
CMD="${CMD} MODULE(${MODULES})"
CMD="${CMD} BNDSRVPGM(${TARGETLIB}/${SRVPGM} QADRTTS)"
CMD="${CMD} TGTRLS(${TGTRLS})"
CLcommand "${CMD}"
fi
done
build_all_programs "" "${TARGETLIB}/${SRVPGM}"
)
6 changes: 5 additions & 1 deletion tests/server/disabled.c
Expand Up @@ -91,9 +91,13 @@ static const char *disabled[]={
NULL
};

int main(void)
int main(int argc, char **argv)
{
int i;

(void) argc;
(void) argv;

for(i = 0; disabled[i]; i++)
printf("%s\n", disabled[i]);

Expand Down

0 comments on commit aafe43a

Please sign in to comment.