From: Martin R. <mr...@us...> - 2004-04-22 19:16:49
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/epoll In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1412 Modified Files: Makefile Added Files: CheckVer.c Log Message: Changes to detect glibc versions. --- NEW FILE: CheckVer.c --- /******************************************************************************/ /* */ /* 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 */ /* */ /******************************************************************************/ /****************************************************************************** File: CheckVer.c Description: Takes version numbers of software (or anything else for that matter) Compares them and then returns: 0 - Older - The version passed is older than the required version 1 - Newer or matching - The version passed is at least the required version -1 - some kind of error condition This is a very simple program so very little error checking is done. mr...@us... - Initial version ******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <stdarg.h> #include <string.h> #define DEBUG 1 #define MIN_ARGS 2 #define MIN_VER_LEN 255 // Seems like that should be enough #define JUMP_POINT 2 int main (int argc, char *argv[]) { int version = 1; int BaseVerLen, CurrentVerLen, i = 0; char BaseVersion[MIN_VER_LEN]; char CurrentVersion[MIN_VER_LEN]; if (argc < MIN_ARGS) { printf("Returning not enough params\n"); exit (2); } strcpy(BaseVersion, argv[1]); strcpy(CurrentVersion, argv[2]); BaseVerLen = strlen(BaseVersion); CurrentVerLen = strlen(CurrentVersion); if (DEBUG) { printf("BaseVersion = %s \n", BaseVersion); printf("CurrentVersion = %s \n", CurrentVersion); } if (BaseVersion[i] > CurrentVersion[i]) { printf("Way too old\n"); version = 0; } i+=JUMP_POINT; if (i <= BaseVerLen && i < CurrentVerLen) { if (version && BaseVersion[i] > CurrentVersion[i]) { printf("Just too old\n"); version = 0; } } else if (BaseVerLen > CurrentVerLen){ printf("Not enough points\n"); version = 0; } i+=JUMP_POINT; if (i <= BaseVerLen && i < CurrentVerLen) { if (version && BaseVersion[i] > CurrentVersion[i]) { printf("Just a little too old\n"); version = 0; } } else if (BaseVerLen > CurrentVerLen){ printf("Not enough points\n"); version = 0; } i+=JUMP_POINT; if (i <= BaseVerLen && i < CurrentVerLen) { if (version && BaseVersion[i] > CurrentVersion[i]) { printf("Just a smidge too old\n"); version = 0; } } else if (BaseVerLen > CurrentVerLen){ printf("Not enough points\n"); version = 0; } if (DEBUG) { printf("Returning %d \n", version); } exit (version); } Index: Makefile =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/epoll/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 11 Mar 2004 16:10:37 -0000 1.2 --- Makefile 22 Apr 2004 19:16:40 -0000 1.3 *************** *** 1,6 **** CFLAGS+= -Wall -O -g -I../../../../include LDLIBS+= -L /lib -L../../../../lib -lepoll -lltp ! TARGETS=epoll-ltp SRCS=$(wildcard *.c) OBJS=$(patsubst %.c,%.o,$(SRCS)) --- 1,19 ---- CFLAGS+= -Wall -O -g -I../../../../include + + LIBC_VER=$(shell ldd --version | grep libc | cut -d " " -f4) + CUR_LIBC_VER:=$(LIBC_VER) + EPOLL_INC:=2.3.2 + VER_LEVEL=$(shell ./CheckVer $(EPOLL_INC) $(CUR_LIBC_VER) | grep Return | cut -d " " -f2) + BASE_VER=1 + + ifneq (${BASE_VER},${VER_LEVEL}) LDLIBS+= -L /lib -L../../../../lib -lepoll -lltp + else + LDLIBS+= -lltp + endif ! ! ! TARGETS=CheckVer epoll-ltp SRCS=$(wildcard *.c) OBJS=$(patsubst %.c,%.o,$(SRCS)) *************** *** 9,13 **** epoll-ltp: epoll-ltp.o ! $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) install: --- 22,29 ---- epoll-ltp: epoll-ltp.o ! $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) ! ! CheckVer: CheckVer.o ! $(CC) -o $@ $^ $(CFLAGS) install: *************** *** 16,17 **** --- 32,34 ---- clean: rm -f $(OBJS) $(TARGETS) + |