begin to make test cases productive

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-02-02 11:10:19 +01:00
commit 63a0e8184d
2 changed files with 0 additions and 0 deletions

View file

@ -1,87 +0,0 @@
#!/bin/sh
#
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# Let's build a cconfig tree from a generic configuration (example)
#
#[ $# -eq 1 ] || __cdist_usage "cconf"
. cdist-config
set -au
# all types cdist is aware of
export cdist_types="file service user"
# the file that contains mapping from hosts to types
# we will execute this later -- call this MANIFEST?
cdist_config_base="./EXAMPLE_MANIFEST"
cdist_tree_wrapper="./cdist_tree_wrapper"
# used to build the tree and other stuff
tmpdir=/tmp/cdist-test-hardcoded
cdist_bindir="${tmpdir}/bin"
cdist_confdir="${tmpdir}/conf"
cdist_type_prefix="__"
################################################################################
# Begin execution
cdist_tree_wrapper_name=${cdist_tree_wrapper##*/}
cdist_tree_wrapper_absdir=$(cd ${cdist_tree_wrapper%/*} && pwd -P)
cdist_tree_wrapper_abs="$cdist_tree_wrapper_absdir/$cdist_tree_wrapper_name"
rm -rf "${tmpdir}"
# contains cdist-tree binaries
mkdir -p "${cdist_bindir}"
#ln -s "${cdist_tree_wrapper_abs}" "${bindir}"
# Create our binaries, will are called from the manifest - temporary
(
set -e
cd "${cdist_bindir}"
for bin in $cdist_types; do
ln -s "${cdist_tree_wrapper_abs}" "${cdist_type_prefix}${bin}"
done
)
# Cdist_tree_wrapper does not need any other tool, so remove them from the path.
# but the manifest may need so - FIXME: think about it.
#unset PATH
# prepend our path
PATH="${cdist_bindir}:$PATH"
# create output dir
mkdir -p "${cdist_confdir}"
# force -x, so the user is aware the file is executed
if [ -x "${cdist_config_base}" ]; then
"${cdist_config_base}"
else
echo Throw some error, as you forgot to +x it.
exit 1
fi
echo "Finished tree generation, have a look at ${cdist_confdir}."

View file

@ -1,70 +0,0 @@
#!/bin/sh
#
# 2010 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# Wrapper script that generates cconfig from arguments
#
# This script will be called everytime the manifest decides to create
# a new type
#
. cdist-config
[ $# -ge 1 ] || __cdist_usage "<id> <options>"
echo "I am $__cdist_myname and have been called with $@"
id="$1"; shift
# FIXME: find a better definiton of sane (i.e. everything that is a valid filename)
sanechars='[A-Za-z0-9_]'
echo "$id" | grep -q "^${sanechars}*\$" || __cdist_usage "Provide sane id, please"
tid="${__cdist_myname}/${id}"
ddir="${cdist_confdir}/${tid}"
if [ -e "${ddir}" ]; then
# FIXME: add source! $cdist_config_base/source
# FIXME: force $source information to be present from outside!
__cdist_usage "${tid} already exists"
fi
mkdir -p "${ddir}"
while [ $# -gt 0 ]; do
opt="$1"; shift
echo "$opt" | grep -q "^--${sanechars}*\$" || __cdist_usage "Provide sane options"
opt_file="$(echo $opt | sed 's/^--//')"
# FIXME: check for options supported by type - or leave it to the type?
# I guess do it here, so we also check whether
[ $# -ge 1 ] || __cdist_usage "Missing value for $opt"
value="$1"; shift
echo "${value}" > "${ddir}/${opt_file}"
done