⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5-2.c

📁 最新rtlinux内核源码
💻 C
字号:
/*    * Copyright (c) 2002, Intel Corporation. All rights reserved. * Created by:  julie.n.fleischer REMOVE-THIS AT intel DOT com * This file is licensed under the GPL license.  For the full content * of this license, see the COPYING file at the top level of this  * source tree. * Test that timer_delete() returns -1 and sets errno==EINVAL when * trying to delete a timer that has already been deleted. * Steps: * - Run test case 1-1.c and then try to delete the timer again. * * For this test, signal SIGTOTEST will be used, clock CLOCK_REALTIME * will be used. */#include <time.h>#include <signal.h>#include "compat.h"#include <errno.h>#include "posixtest.h"#define SIGTOTEST SIGALRM#define TIMERSEC 3void handler(int signo){	printf("Should not have caught signal\n");	exit(PTS_FAIL);}int init_module(void){	struct sigevent ev;	struct sigaction act;	timer_t tid;	struct itimerspec its;	ev.sigev_notify = SIGEV_SIGNAL;	ev.sigev_signo = SIGTOTEST;	act.sa_handler=handler;	act.sa_flags=0;	its.it_interval.tv_sec = 0;	its.it_interval.tv_nsec = 0;	its.it_value.tv_sec = TIMERSEC;	its.it_value.tv_nsec = 0;	/*	if (sigemptyset(&act.sa_mask) == -1) {		perror("Error calling sigemptyset\n");		return PTS_UNRESOLVED;	}	*/	if (sigaction(SIGTOTEST, &act, 0) == -1) {		perror("Error calling sigaction\n");		return PTS_UNRESOLVED;	}	if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) {		perror("timer_create() did not return success\n");		return PTS_UNRESOLVED;	}	if (timer_settime(tid, 0, &its, NULL) != 0) {		perror("timer_settime() did not return success\n");		return PTS_UNRESOLVED;	}	if (timer_delete(tid) != 0) {		perror("timer_delete() did not return success\n");		return PTS_UNRESOLVED;	}	if (sleep(TIMERSEC) != 0) {		printf("sleep() did not sleep full time\n");		return PTS_UNRESOLVED;	}	if (timer_delete(tid) == -1) {		if (errno==EINVAL) {			printf("Test PASSED\n");			return PTS_PASS;		} else {			printf("errno!=EINVAL when deleted timer ID sent\n");			return PTS_FAIL;		}	} else {		printf("timer_delete() didn't return -1 on deleted timer ID\n");		return PTS_FAIL;	}	printf("This code should never be executed\n");	return PTS_UNRESOLVED;}void cleanup_module(void){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -