Blame agen5/test/license.test

Packit Service 96b5d3
#! /bin/sh
Packit Service 96b5d3
#  -*- Mode: Shell-script -*-
Packit Service 96b5d3
# license.test --- test license 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
Packit Service 96b5d3
# # # # # # # # # # TEMPLATE FILE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.tpl
Packit Service 96b5d3
cat > ${testname}.tpl <<_EOF_
Packit Service 96b5d3
[= AutoGen5 template test =]
Packit Service 96b5d3
/*
Packit Service 96b5d3
[= (license "${testname}" "${testname}" "Auto-Gen" " *  " ) =]
Packit Service 96b5d3
 */
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # LICENSE FILE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
echo creating ${testname}.lic
Packit Service 96b5d3
cat > ${testname}.lic <<'_EOF_'
Packit Service 96b5d3
This is a bogus license granted by %2$s for %1$s.
Packit Service 96b5d3
Use it in good health
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # EXTEND FILES TO PAGESIZE # # # # # # # # #
Packit Service 96b5d3
Packit Service 96b5d3
cat > ${testname}-extend.c <<- _EOF_
Packit Service 96b5d3
	#define HAVE_CONFIG_H 1
Packit Service 96b5d3
	#include "config.h"
Packit Service 96b5d3
	#include "compat/compat.h"
Packit Service 96b5d3
Packit Service 96b5d3
	int main( int argc, char** argv ) {
Packit Service 96b5d3
	char z_tail[] = "=]\n */\n";
Packit Service 96b5d3
	long offset = 0L - (sizeof(z_tail) - 1);
Packit Service 96b5d3
	struct stat sb;
Packit Service 96b5d3
	char* file;
Packit Service 96b5d3
	size_t sz;
Packit Service 96b5d3
	FILE* fp;
Packit Service 96b5d3
Packit Service 96b5d3
	file = *++argv;
Packit Service 96b5d3
	fp = fopen(file, "a");
Packit Service 96b5d3
	if (fp == NULL) return 1;
Packit Service 96b5d3
	if (stat(file, &sb) != 0) return 1;
Packit Service 96b5d3
	sz = 0x2000 - (sb.st_size & 0x1FFFUL);
Packit Service 96b5d3
	while (sz > 0) { putc( '\n', fp ); sz--; }
Packit Service 96b5d3
	fclose(fp);
Packit Service 96b5d3
Packit Service 96b5d3
	file = *++argv;
Packit Service 96b5d3
	fp = fopen( file, "r+" );
Packit Service 96b5d3
	if (fp == NULL) return 1;
Packit Service 96b5d3
	if (stat(file, &sb) != 0) return 1;
Packit Service 96b5d3
	fseek(fp, offset, SEEK_END);
Packit Service 96b5d3
	sz = 0x2000 - (sb.st_size & 0x1FFFUL);
Packit Service 96b5d3
	while (sz > 0) { putc( '\n', fp ); sz--; }
Packit Service 96b5d3
	fputs(z_tail, fp);
Packit Service 96b5d3
	fclose(fp);
Packit Service 96b5d3
Packit Service 96b5d3
	return 0; }
Packit Service 96b5d3
	_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
Csrc=${testname}-extend
Packit Service 96b5d3
compile
Packit Service 96b5d3
Packit Service 96b5d3
./${testname}-extend ${testname}.lic ${testname}.tpl || \
Packit Service 96b5d3
  failure "Could not extend license/template files to 8KB"
Packit Service 96b5d3
ls -l ${testname}.???
Packit Service 96b5d3
Packit Service 96b5d3
# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # #
Packit Service 96b5d3
set -x
Packit Service 96b5d3
echo creating ${testname}.out
Packit Service 96b5d3
# this is the output we should expect to see
Packit Service 96b5d3
cat > ${testname}.out <<_EOF_
Packit Service 96b5d3
/*
Packit Service 96b5d3
 *  This is a bogus license granted by Auto-Gen for ${testname}.
Packit Service 96b5d3
 *  Use it in good health
Packit Service 96b5d3
 */
Packit Service 96b5d3
_EOF_
Packit Service 96b5d3
Packit Service 96b5d3
run_ag x -b ${testname} --no-def -T ${testname}.tpl || \
Packit Service 96b5d3
    failure autogen failed
Packit Service 96b5d3
cmp -s ${testname}.test ${testname}.out || failure unexpected output
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: 2
Packit Service 96b5d3
## sh-basic-offset: 2
Packit Service 96b5d3
## End:
Packit Service 96b5d3
Packit Service 96b5d3
# end of license.test