From: <ky...@us...> - 2007-03-21 14:21:00
|
Revision: 419 http://svn.sourceforge.net/crackerjack/?rev=419&view=rev Author: kyagi Date: 2007-03-21 07:20:53 -0700 (Wed, 21 Mar 2007) Log Message: ----------- add Added Paths: ----------- trunk/crackerjack/testcases/old_select/ trunk/crackerjack/testcases/old_select/Makefile trunk/crackerjack/testcases/old_select/old_select_test.c Added: trunk/crackerjack/testcases/old_select/Makefile =================================================================== --- trunk/crackerjack/testcases/old_select/Makefile (rev 0) +++ trunk/crackerjack/testcases/old_select/Makefile 2007-03-21 14:20:53 UTC (rev 419) @@ -0,0 +1,42 @@ +# +# Crackerjack Project +# +# Copyright (C) 2007 Miracle Linux Corp, All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Further, this software is distributed without any warranty that it is +# free of the rightful claim of any third person regarding infringement +# or the like. Any license provided herein, whether implied or +# otherwise, applies only to this software file. Patent licenses, if +# any, provided herein do not apply to combinations of this program with +# other software, or any other product whatsoever. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston MA 02111-1307, USA. +# +# #ID +# + +CFLAGS = -g -Wall +SRC = $(wildcard *_test.c) + +test: $(SRC) Makefile + $(CC) -o $@ $(CFLAGS) $< + +check: test + ./test > test.log.1 + sleep 1 + ./test > test.log.2 + ./compare test.log.1 test.log.2 + /bin/rm -rf test.log.* + +clean: + /bin/rm -rf test.log.* test Added: trunk/crackerjack/testcases/old_select/old_select_test.c =================================================================== --- trunk/crackerjack/testcases/old_select/old_select_test.c (rev 0) +++ trunk/crackerjack/testcases/old_select/old_select_test.c 2007-03-21 14:20:53 UTC (rev 419) @@ -0,0 +1,65 @@ +/* + * Crackerjack Project + * + * Copyright (C) 2007 Miracle Linux Corp, All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Further, this software is distributed without any warranty that it is + * free of the rightful claim of any third person regarding infringement + * or the like. Any license provided herein, whether implied or + * otherwise, applies only to this software file. Patent licenses, if + * any, provided herein do not apply to combinations of this program with + * other software, or any other product whatsoever. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston MA 02111-1307, USA. + * + * $Id$ + */ + +#include <stdio.h> +#include <sys/time.h> +#include <sys/types.h> +#include <unistd.h> +#include <errno.h> +#include <sys/stat.h> +#include <fcntl.h> + +#define PRINT(X) printf("%s\n", X) +#define OK PRINT("OK") +#define NG PRINT("NG") + +int +main(int argc, char **argv) +{ + int ret; + fd_set readset; + struct timeval tv; + + FD_ZERO(&readset); + FD_SET(STDIN_FILENO, &readset); + tv.tv_sec = 1; + tv.tv_usec = 0; + + ret = select(1, &readset, NULL, NULL, &tv); + if (ret == -1) { + perror("select"); + NG; + return 1; + } else if (ret != 0) { + NG; + + + } + + OK; + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |