|
From: <ro...@us...> - 2003-01-03 21:42:19
|
Update of /cvsroot/ltp/ltp/testcases/misc/math/abs
In directory sc8-pr-cvs1:/tmp/cvs-serv3101/testcases/misc/math/abs
Added Files:
Makefile abs01.c
Log Message:
Added abs() test ported by Ananda Venkataraman.
--- NEW FILE: Makefile ---
#
# Copyright (c) International Business Machines Corp., 2001
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU 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
#
###########################################################################
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g
LOADLIBES+= -lm -L../../../../lib -lltp
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
all: $(TARGETS)
install:
@for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
clean:
rm -f $(TARGETS)
--- NEW FILE: abs01.c ---
/* IBM Corporation */
/* 01/02/2003 Port to LTP av...@us... */
/* 06/30/2001 Port to Linux nsh...@us... */
/*
* $Copyright: $
* Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989
* Sequent Computer Systems, Inc. All rights reserved.
*
* This software is furnished under a license and may be used
* only in accordance with the terms of that license and with the
* inclusion of the above copyright notice. This software may not
* be provided or otherwise made available to, or used by, any
* other person. No title to or ownership of the software is
* hereby transferred.
*/
/*
* NAME
* abs -- absolute integer value
*
* CALLS
* abs(3)
*
* ALGORITHM
* Check with variables. Also most neg value as listed
* on man page.
*
* RESTRICTIONS
* considered a long time - estimate this one
*/
#include <stdio.h> /* needed by testhead.h */
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <math.h>
#include <errno.h>
#include <values.h>
/***** LTP Port *****/
#include "test.h"
#include "usctest.h"
#define FAILED 0
#define PASSED 1
char *TCID = "abs01";
int local_flag = PASSED;
int block_number;
int errno;
FILE * temp;
int TST_TOTAL =1;
extern int Tst_count;
void setup();
int blenter();
int blexit();
/********************************/
/*--------------------------------------------------------------*/
int main (argc, argv)
int argc;
char *argv[];
{
register int i,j, k, l;
setup(); /* temp file is now open */
/*--------------------------------------------------------------*/
blenter();
i = abs(MININT);
if (i != MININT) {
fprintf(temp, "abs of minimum integer failed.");
local_flag = FAILED;
}
blexit();
/*--------------------------------------------------------------*/
blenter();
i = abs(0);
if (i != 0) {
fprintf(temp, "abs(0) failed, returned 0x%x\n", i);
local_flag = FAILED;
}
blexit();
/*--------------------------------------------------------------*/
blenter();
for (i = 1; i >= 0 ; i <<= 1) {
j = ~i;
k = j + 1;
l = abs(k);
if (l != i)
local_flag = FAILED;
}
blexit();
/*--------------------------------------------------------------*/
/* Clean up any files created by test before call to anyfail. */
tst_exit(); /* THIS CALL DOES NOT RETURN - EXITS!! */
return(0);
}
/*--------------------------------------------------------------*/
/***** LTP Port *****/
void setup()
{
temp = stderr;
}
int blenter()
{
local_flag = PASSED;
return(0);
}
int blexit()
{
(local_flag == PASSED ) ? tst_resm(TPASS, "Test passed\n") : tst_resm(TFAIL, "Test failed\n");
return(0);
}
/****** *****/
|