Blame agen5/test/str2m.test

Packit Service 96b5d3
#! /bin/sh
Packit Service 96b5d3
#  -*- Mode: Shell-script -*-
Packit Service 96b5d3
# str2m.test --- test str2enum and str2mask functionality
Packit Service 96b5d3
#
Packit Service 96b5d3
# Author:            Bruce Korb <bkorb@gnu.org>
Packit Service 96b5d3
##
Packit Service 96b5d3
## This file is part of AutoGen.
Packit Service 96b5d3
## AutoGen Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
Packit Service 96b5d3
##
Packit Service 96b5d3
## AutoGen is free software: you can redistribute it and/or modify it
Packit Service 96b5d3
## under the terms of the GNU General Public License as published by the
Packit Service 96b5d3
## Free Software Foundation, either version 3 of the License, or
Packit Service 96b5d3
## (at your option) any later version.
Packit Service 96b5d3
##
Packit Service 96b5d3
## AutoGen is distributed in the hope that it will be useful, but
Packit Service 96b5d3
## WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 96b5d3
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit Service 96b5d3
## See the GNU General Public License for more details.
Packit Service 96b5d3
##
Packit Service 96b5d3
## You should have received a copy of the GNU General Public License along
Packit Service 96b5d3
## with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 96b5d3
##
Packit Service 96b5d3
#
Packit Service 96b5d3
# ----------------------------------------------------------------------
Packit Service 96b5d3
Packit Service 96b5d3
. ./defs
Packit Service 96b5d3
gperf=`command -v gperf`
Packit Service 96b5d3
test -x "$gperf" || {
Packit Service 96b5d3
    echo "$0 - cannot run without gperf installed" >&2
Packit Service 96b5d3
    exit 0
Packit Service 96b5d3
}
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # DEFINITIONS FILE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating $testname.def
Packit Service 96b5d3
cat > $testname.def <<'_EOF_'
Packit Service 96b5d3
AutoGen Definitions str2enum;
Packit Service 96b5d3
Packit Service 96b5d3
cmd[0]  = one;
Packit Service 96b5d3
cmd[3]  = three;
Packit Service 96b5d3
cmd[7]  = seven;
Packit Service 96b5d3
cmd[11] = eleven;
Packit Service 96b5d3
cmd[19] = ninteen;
Packit Service 96b5d3
Packit Service 96b5d3
type = kwd;
Packit Service 96b5d3
mask = { m-name = one-seven; m-bit = one, seven; };
Packit Service 96b5d3
mask = { m-name = not-one-seven; m-bit = three, eleven, ninteen; m-invert; };
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
cmd_list=`${SED} -n '/^cmd/{s/.*= *//;s/;//;p;}' $testname.def`
Packit Service 96b5d3
cmd_list=`echo $cmd_list`
Packit Service 96b5d3
# # # # # # # # # # EXPECTED OUTPUT FILES # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating $testname-h.base
Packit Service 96b5d3
# this is the output we should expect to see
Packit Service 96b5d3
cat > $testname-h.base <<- _EOF_
Packit Service 96b5d3
	typedef enum {
Packit Service 96b5d3
	    STR2M_INVALID_KWD = 0,
Packit Service 96b5d3
	    STR2M_KWD_ONE      = 1,
Packit Service 96b5d3
	    STR2M_KWD_THREE    = 4,
Packit Service 96b5d3
	    STR2M_KWD_SEVEN    = 8,
Packit Service 96b5d3
	    STR2M_KWD_ELEVEN   = 12,
Packit Service 96b5d3
	    STR2M_KWD_NINTEEN  = 20,
Packit Service 96b5d3
	    STR2M_COUNT_KWD
Packit Service 96b5d3
	} str2m_enum_t;
Packit Service 96b5d3
Packit Service 96b5d3
	extern str2m_enum_t
Packit Service 96b5d3
	find_str2m_kwd(char const * str, size_t len);
Packit Service 96b5d3
Packit Service 96b5d3
	extern char const *
Packit Service 96b5d3
	str2m_name(str2m_enum_t id);
Packit Service 96b5d3
Packit Service 96b5d3
	#endif /* STR2ENUM_STR2M_H_GUARD */
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
cat > $testname-c.base <<- _EOF_
Packit Service 96b5d3
	 * Convert a command (keyword) to a str2m_enum_t enumeration value.
Packit Service 96b5d3
	 *
Packit Service 96b5d3
	 * @param[in] str   a string that should start with a known key word.
Packit Service 96b5d3
	 * @param[in] len   the provided length of the keyword at \a str.
Packit Service 96b5d3
	 * @returns the enumeration value.
Packit Service 96b5d3
	 * If not found, that value is STR2M_INVALID_KWD.
Packit Service 96b5d3
	 */
Packit Service 96b5d3
	str2m_enum_t
Packit Service 96b5d3
	find_str2m_kwd(char const * str, size_t len)
Packit Service 96b5d3
	{
Packit Service 96b5d3
	    str2m_map_t const * map;
Packit Service 96b5d3
Packit Service 96b5d3
	    map = find_str2m_name(str, (unsigned int)len);
Packit Service 96b5d3
	    return (map == NULL) ? STR2M_INVALID_KWD : map->str2m_id;
Packit Service 96b5d3
	}
Packit Service 96b5d3
Packit Service 96b5d3
	/**
Packit Service 96b5d3
	 * Convert an str2m_enum_t value into a string.
Packit Service 96b5d3
	 *
Packit Service 96b5d3
	 * @param[in] id  the enumeration value
Packit Service 96b5d3
	 * @returns the associated string, or "* UNDEFINED *" if \a id
Packit Service 96b5d3
	 * is out of range.
Packit Service 96b5d3
	 */
Packit Service 96b5d3
	char const *
Packit Service 96b5d3
	str2m_name(str2m_enum_t id)
Packit Service 96b5d3
	{
Packit Service 96b5d3
	    static char const undef[] = "* UNDEFINED *";
Packit Service 96b5d3
	    static char const * const nm_table[] = {
Packit Service 96b5d3
	        [STR2M_KWD_ELEVEN  ] = "eleven",
Packit Service 96b5d3
	        [STR2M_KWD_NINTEEN ] = "ninteen",
Packit Service 96b5d3
	        [STR2M_KWD_ONE     ] = "one",
Packit Service 96b5d3
	        [STR2M_KWD_SEVEN   ] = "seven",
Packit Service 96b5d3
	        [STR2M_KWD_THREE   ] = "three" };
Packit Service 96b5d3
	    char const * res = undef;
Packit Service 96b5d3
	    if (id < STR2M_COUNT_KWD) {
Packit Service 96b5d3
	        res = nm_table[id];
Packit Service 96b5d3
	        if (res == NULL)
Packit Service 96b5d3
	            res = undef;
Packit Service 96b5d3
	    }
Packit Service 96b5d3
	    return res;
Packit Service 96b5d3
	}
Packit Service 96b5d3
Packit Service 96b5d3
	/* end of str2m.c */
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # RUN THE TEST # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
AGCMD="-L ${srcdir}/.. -L ${top_srcdir}/autoopts/tpl"
Packit Service 96b5d3
echo run_ag x ${AGCMD} $testname.def
Packit Service 96b5d3
run_ag x ${AGCMD} $testname.def || \
Packit Service 96b5d3
    failure ${AGCMD} failed
Packit Service 96b5d3
Packit Service 96b5d3
get_h_text="/^typedef enum/,/#endif.*GUARD/p"
Packit Service 96b5d3
${SED} -n "${get_h_text}" $testname.h > $testname-h.res
Packit Service 96b5d3
fpair="$testname-h.base $testname-h.res"
Packit Service 96b5d3
cmp -s $fpair || \
Packit Service 96b5d3
    failure "$testname $fpair failed`echo
Packit Service 96b5d3
        diff $fpair`"
Packit Service 96b5d3
get_c_text="/ Convert .*to a ${testname}_enum_t/,/end of $testname.c/p"
Packit Service 96b5d3
${SED} -n "${get_c_text}" $testname.c > $testname-c.res
Packit Service 96b5d3
Packit Service 96b5d3
fpair="$testname-c.base $testname-c.res"
Packit Service 96b5d3
cmp -s $fpair || \
Packit Service 96b5d3
    failure "$testname $fpair failed`echo
Packit Service 96b5d3
        diff $fpair`"
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # OUTPUT FILES PART 2 # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating $testname-h2.base
Packit Service 96b5d3
TNAME=`echo $testname | tr '[a-z]' '[A-Z]'`
Packit Service 96b5d3
rep_name="s/${testname}/${testname}_2/g;s/${TNAME}/${TNAME}_2/g"
Packit Service 96b5d3
cat > $testname-h2.base <<- _EOF_
Packit Service 96b5d3
	#ifndef STR2ENUM_STR2M_2_H_GUARD
Packit Service 96b5d3
	#define STR2ENUM_STR2M_2_H_GUARD 1
Packit Service 96b5d3
	#include <sys/types.h>
Packit Service 96b5d3
	#include <inttypes.h>
Packit Service 96b5d3
Packit Service 96b5d3
	/** integral type for holding str2m_2 masks */
Packit Service 96b5d3
	typedef uint32_t str2m_2_mask_t;
Packit Service 96b5d3
Packit Service 96b5d3
	/** bits defined for str2m_2_mask_t */
Packit Service 96b5d3
	#define STR2M_2_KWD_ONE                0x00001U
Packit Service 96b5d3
	#define STR2M_2_KWD_THREE              0x00008U
Packit Service 96b5d3
	#define STR2M_2_KWD_SEVEN              0x00080U
Packit Service 96b5d3
	#define STR2M_2_KWD_ELEVEN             0x00800U
Packit Service 96b5d3
	#define STR2M_2_KWD_NINTEEN            0x80000U
Packit Service 96b5d3
Packit Service 96b5d3
	/** bits in ONE_SEVEN mask:
Packit Service 96b5d3
	 *  one   seven */
Packit Service 96b5d3
	#define STR2M_2_KWD_ONE_SEVEN_MASK     0x00081U
Packit Service 96b5d3
Packit Service 96b5d3
	/** bits omitted from NOT_ONE_SEVEN mask:
Packit Service 96b5d3
	 *  three   eleven  ninteen */
Packit Service 96b5d3
	#define STR2M_2_KWD_NOT_ONE_SEVEN_MASK 0x00081U
Packit Service 96b5d3
Packit Service 96b5d3
	/** all bits in str2m_2_mask_t masks */
Packit Service 96b5d3
	#define STR2M_2_KWD_MASK_ALL           0x80889U
Packit Service 96b5d3
Packit Service 96b5d3
	/** no bits in str2m_2_mask_t */
Packit Service 96b5d3
	#define STR2M_2_KWD_EMPTY              0x00000U
Packit Service 96b5d3
Packit Service 96b5d3
	/** buffer size needed to hold all bit names for str2m_2_mask_t masks */
Packit Service 96b5d3
	#define MAX_STR2M_2_NAME_SIZE 31
Packit Service 96b5d3
Packit Service 96b5d3
	extern str2m_2_mask_t
Packit Service 96b5d3
	str2m_2_str2mask(char const * str, str2m_2_mask_t old);
Packit Service 96b5d3
Packit Service 96b5d3
	extern size_t
Packit Service 96b5d3
	str2m_2_mask2str(str2m_2_mask_t mask, char * buf, size_t len);
Packit Service 96b5d3
Packit Service 96b5d3
	#endif /* STR2ENUM_STR2M_2_H_GUARD */
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
mask_all=`
Packit Service 96b5d3
    sed -n '/KWD_MASK_ALL/{;s/.*0x/0x/;s/UL*$//;p;q;}' $testname-h2.base`
Packit Service 96b5d3
Packit Service 96b5d3
cat > $testname-c2.base <<- _EOF_
Packit Service 96b5d3
	 * Convert a command (keyword) to a str2m_2_enum_t enumeration value.
Packit Service 96b5d3
	 *
Packit Service 96b5d3
	 * @param[in] str   a string that should start with a known key word.
Packit Service 96b5d3
	 * @param[in] len   the provided length of the keyword at \a str.
Packit Service 96b5d3
	 * @returns the enumeration value.
Packit Service 96b5d3
	 * If not found, that value is STR2M_2_COUNT_KWDBNM.
Packit Service 96b5d3
	 */
Packit Service 96b5d3
	static str2m_2_enum_t
Packit Service 96b5d3
	find_str2m_2_kwdbnm(char const * str, size_t len)
Packit Service 96b5d3
	{
Packit Service 96b5d3
	    str2m_2_map_t const * map;
Packit Service 96b5d3
Packit Service 96b5d3
	    map = find_str2m_2_name(str, (unsigned int)len);
Packit Service 96b5d3
	    return (map == NULL) ? STR2M_2_COUNT_KWDBNM : map->str2m_2_id;
Packit Service 96b5d3
	}
Packit Service 96b5d3
Packit Service 96b5d3
	/**
Packit Service 96b5d3
	 * Convert an str2m_2_enum_t value into a string.
Packit Service 96b5d3
	 *
Packit Service 96b5d3
	 * @param[in] id  the enumeration value
Packit Service 96b5d3
	 * @returns the associated string, or "* UNDEFINED *" if \a id
Packit Service 96b5d3
	 * is out of range.
Packit Service 96b5d3
	 */
Packit Service 96b5d3
	static char const *
Packit Service 96b5d3
	str2m_2_name(str2m_2_enum_t id)
Packit Service 96b5d3
	{
Packit Service 96b5d3
	    static char const undef[] = "* UNDEFINED *";
Packit Service 96b5d3
	    static char const * const nm_table[] = {
Packit Service 96b5d3
	        [STR2M_2_KWDBNM_ELEVEN  ] = "eleven",
Packit Service 96b5d3
	        [STR2M_2_KWDBNM_NINTEEN ] = "ninteen",
Packit Service 96b5d3
	        [STR2M_2_KWDBNM_ONE     ] = "one",
Packit Service 96b5d3
	        [STR2M_2_KWDBNM_SEVEN   ] = "seven",
Packit Service 96b5d3
	        [STR2M_2_KWDBNM_THREE   ] = "three" };
Packit Service 96b5d3
	    char const * res = undef;
Packit Service 96b5d3
	    if (id < STR2M_2_COUNT_KWDBNM) {
Packit Service 96b5d3
	        res = nm_table[id];
Packit Service 96b5d3
	        if (res == NULL)
Packit Service 96b5d3
	            res = undef;
Packit Service 96b5d3
	    }
Packit Service 96b5d3
	    return res;
Packit Service 96b5d3
	}
Packit Service 96b5d3
Packit Service 96b5d3
	#include <sys/types.h>
Packit Service 96b5d3
	#include <string.h>
Packit Service 96b5d3
	#ifndef NUL
Packit Service 96b5d3
	#define NUL '\0'
Packit Service 96b5d3
	#endif
Packit Service 96b5d3
Packit Service 96b5d3
	/**
Packit Service 96b5d3
	 * Convert a string to a str2m_2_mask_t mask.
Packit Service 96b5d3
	 * Bit names prefixed with a hyphen have the bit removed from the mask.
Packit Service 96b5d3
	 * If the string starts with a '-', '+' or '|' character, then
Packit Service 96b5d3
	 * the old value is used as a base, otherwise the result mask
Packit Service 96b5d3
	 * is initialized to zero.  Separating bit names with '+' or '|'
Packit Service 96b5d3
	 * characters is optional.  By default, the bits are "or"-ed into the
Packit Service 96b5d3
	 * result.
Packit Service 96b5d3
	 *
Packit Service 96b5d3
	 * @param[in] str string with a list of bit names
Packit Service 96b5d3
	 * @param[in] old previous value, used if \a str starts with a '+' or '-'.
Packit Service 96b5d3
	 *
Packit Service 96b5d3
	 * @returns an unsigned integer with the bits set.
Packit Service 96b5d3
	 */
Packit Service 96b5d3
	str2m_2_mask_t
Packit Service 96b5d3
	str2m_2_str2mask(char const * str, str2m_2_mask_t old)
Packit Service 96b5d3
	{
Packit Service 96b5d3
	    static char const white[] = " \t\f";
Packit Service 96b5d3
	    static char const name_chars[] =
Packit Service 96b5d3
	        "ehilnorstv"
Packit Service 96b5d3
	        "EHILNORSTV";
Packit Service 96b5d3
Packit Service 96b5d3
	    str2m_2_mask_t res = 0;
Packit Service 96b5d3
	    int have_data = 0;
Packit Service 96b5d3
Packit Service 96b5d3
	    for (;;) {
Packit Service 96b5d3
	        str2m_2_enum_t val;
Packit Service 96b5d3
	        unsigned int val_len;
Packit Service 96b5d3
	        unsigned int invert = 0;
Packit Service 96b5d3
	
Packit Service 96b5d3
	        str += strspn(str, white);
Packit Service 96b5d3
	        switch (*str) {
Packit Service 96b5d3
	        case NUL: return res;
Packit Service 96b5d3
	        case '-': case '~':
Packit Service 96b5d3
	            invert = 1;
Packit Service 96b5d3
	            /* FALLTHROUGH */
Packit Service 96b5d3
Packit Service 96b5d3
	        case '+': case '|':
Packit Service 96b5d3
	            if (have_data == 0)
Packit Service 96b5d3
	                res = old;
Packit Service 96b5d3
Packit Service 96b5d3
	            str += 1 + strspn(str + 1, white);
Packit Service 96b5d3
	            if (*str == NUL)
Packit Service 96b5d3
	                return 0;
Packit Service 96b5d3
	        }
Packit Service 96b5d3
Packit Service 96b5d3
	        val_len = strspn(str, name_chars);
Packit Service 96b5d3
	        if (val_len == 0)
Packit Service 96b5d3
	            return 0;
Packit Service 96b5d3
	        val = find_str2m_2_kwdbnm(str, val_len);
Packit Service 96b5d3
	        if (val == STR2M_2_COUNT_KWDBNM)
Packit Service 96b5d3
	            return 0;
Packit Service 96b5d3
	        if (invert)
Packit Service 96b5d3
	            res &= ~((str2m_2_mask_t)1 << val);
Packit Service 96b5d3
	        else
Packit Service 96b5d3
	            res |= (str2m_2_mask_t)1 << val;
Packit Service 96b5d3
	        have_data = 1;
Packit Service 96b5d3
	        str += val_len;
Packit Service 96b5d3
	    }
Packit Service 96b5d3
	}
Packit Service 96b5d3
Packit Service 96b5d3
	/**
Packit Service 96b5d3
	 * Convert a str2m_2_mask_t mask to a string.
Packit Service 96b5d3
	 *
Packit Service 96b5d3
	 * @param[in]  mask  the mask with the bits to be named
Packit Service 96b5d3
	 * @param[out] buf   where to store the result.  This may be NULL.
Packit Service 96b5d3
	 * @param[in]  len   size of the output buffer
Packit Service 96b5d3
	 * @results    The full length of the space needed for the result,
Packit Service 96b5d3
	 * including the terminating NUL byte.  The actual result will not
Packit Service 96b5d3
	 * overwrite \a len bytes at \a buf.  This value will also never
Packit Service 96b5d3
	 * exceed MAX_STR2M_2_NAME_SIZE.
Packit Service 96b5d3
	 */
Packit Service 96b5d3
	size_t
Packit Service 96b5d3
	str2m_2_mask2str(str2m_2_mask_t mask, char * buf, size_t len)
Packit Service 96b5d3
	{
Packit Service 96b5d3
	    str2m_2_enum_t val = (str2m_2_enum_t)0;
Packit Service 96b5d3
	    size_t res = 0;
Packit Service 96b5d3
	    if (buf == NULL) len = 0;
Packit Service 96b5d3
Packit Service 96b5d3
	    for (; mask != 0; val++, mask >>= 1) {
Packit Service 96b5d3
	        char const * p;
Packit Service 96b5d3
	        size_t l;
Packit Service 96b5d3
Packit Service 96b5d3
	        if (val >= STR2M_2_COUNT_KWDBNM)
Packit Service 96b5d3
	            break;
Packit Service 96b5d3
Packit Service 96b5d3
	        if ((mask & 1) == 0)
Packit Service 96b5d3
	            continue;
Packit Service 96b5d3
Packit Service 96b5d3
	        p = str2m_2_name(val);
Packit Service 96b5d3
	        if (*p == '*')
Packit Service 96b5d3
	            continue; /* ignore invalid bits */
Packit Service 96b5d3
Packit Service 96b5d3
	        l = strlen(p) + 1; /* includes NUL byte or spacer byte */
Packit Service 96b5d3
	        if (l <= len) {
Packit Service 96b5d3
	            if (res > 0)
Packit Service 96b5d3
	                *(buf++) = ' ';
Packit Service 96b5d3
	            memcpy(buf, p, l);
Packit Service 96b5d3
	            buf += l - 1;
Packit Service 96b5d3
	            len -= l;
Packit Service 96b5d3
	        }
Packit Service 96b5d3
	        res += l;
Packit Service 96b5d3
	    }
Packit Service 96b5d3
	    return (res == 0) ? 1 : res;
Packit Service 96b5d3
	}
Packit Service 96b5d3
	/* end of str2m-2.c */
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # RUN THE TEST PART 2 # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo run_ag x ${AGCMD} -T str2mask $testname.def
Packit Service 96b5d3
echo "base-name = '$testname-2'; prefix = '${testname}_2';" >> $testname.def
Packit Service 96b5d3
run_ag x ${AGCMD} -T str2mask $testname.def || \
Packit Service 96b5d3
    failure ${AGCMD} failed
Packit Service 96b5d3
get_h_text='/#ifndef .*_GUARD/,/#endif .*_GUARD/p'
Packit Service 96b5d3
${SED} -n "${get_h_text}" $testname-2.h > $testname-h2.res
Packit Service 96b5d3
get_c_text=`echo "$get_c_text" | ${SED} "$rep_name"`
Packit Service 96b5d3
${SED} -n "/_names+/d;${get_c_text}" $testname-2.c > $testname-c2.res
Packit Service 96b5d3
Packit Service 96b5d3
fpair="$testname-h2.base $testname-h2.res"
Packit Service 96b5d3
cmp -s $fpair || \
Packit Service 96b5d3
    failure "$testname-2 $fpair failed`echo
Packit Service 96b5d3
        diff $fpair`"
Packit Service 96b5d3
Packit Service 96b5d3
fpair="$testname-c2.base $testname-c2.res"
Packit Service 96b5d3
cmp -s $fpair || \
Packit Service 96b5d3
    failure "$testname-2 $fpair failed`echo
Packit Service 96b5d3
        diff $fpair`"
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # RUN THE TEST PART 3 # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo running $testname-2.c program
Packit Service 96b5d3
chmod 666 $testname-2.c
Packit Service 96b5d3
cmd_sum=`echo $cmd_list | sed 's/ / + /g'`
Packit Service 96b5d3
cat > $testname-main.c <<- _EOF_
Packit Service 96b5d3
	#include <stdio.h>
Packit Service 96b5d3
	#include "$testname-2.c"
Packit Service 96b5d3
	int main(int argc, char ** argv) {
Packit Service 96b5d3
	    str2m_2_mask_t mask =
Packit Service 96b5d3
	        str2m_2_str2mask("${cmd_sum}", 0);
Packit Service 96b5d3
	    char buf[MAX_STR2M_2_NAME_SIZE];
Packit Service 96b5d3
	    size_t l = str2m_2_mask2str(mask, buf, MAX_STR2M_2_NAME_SIZE);
Packit Service 96b5d3
Packit Service 96b5d3
	    printf("0x%04X --> %u bytes: '%s'\n",
Packit Service 96b5d3
	           (unsigned int)mask, (unsigned int)l, buf);
Packit Service 96b5d3
	    if (l != MAX_STR2M_2_NAME_SIZE) {
Packit Service 96b5d3
	        fprintf(stderr, "expected len:  %u, actual:  %u\n",
Packit Service 96b5d3
	                MAX_STR2M_2_NAME_SIZE, (unsigned int)l);
Packit Service 96b5d3
	        return 1;
Packit Service 96b5d3
	    }
Packit Service 96b5d3
	    mask = str2m_2_str2mask("- three - eleven - ninteen", mask);
Packit Service 96b5d3
	    if (mask != STR2M_2_KWD_NOT_ONE_SEVEN_MASK) {
Packit Service 96b5d3
	        fprintf(stderr, "0x%04X != 0x%04X\n", mask,
Packit Service 96b5d3
	                STR2M_2_KWD_NOT_ONE_SEVEN_MASK);
Packit Service 96b5d3
	        return 1;
Packit Service 96b5d3
	    }
Packit Service 96b5d3
	    return 0;
Packit Service 96b5d3
	}
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
${CC:-cc} -o ${testname} $testname-main.c || \
Packit Service 96b5d3
    failure "cannot compile $testname-2.c"
Packit Service 96b5d3
./${testname} > ${testname}-btest
Packit Service 96b5d3
echo "$mask_all --> $(( ${#cmd_list} + 1 )) bytes: '$cmd_list'" \
Packit Service 96b5d3
    > ${testname}-bbase
Packit Service 96b5d3
fpair="${testname}-bbase ${testname}-btest"
Packit Service 96b5d3
cmp -s $fpair || \
Packit Service 96b5d3
    failure "$testname $fpair run failed`echo
Packit Service 96b5d3
        diff $fpair`"
Packit Service 96b5d3
Packit Service 96b5d3
cleanup
Packit Service 96b5d3
Packit Service 96b5d3
## Local Variables:
Packit Service 96b5d3
## mode: shell-script
Packit Service 96b5d3
## indent-tabs-mode: nil
Packit Service 96b5d3
## sh-indentation: 4
Packit Service 96b5d3
## sh-basic-offset: 4
Packit Service 96b5d3
## End:
Packit Service 96b5d3
Packit Service 96b5d3
# end of str2m.test