Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 152932 Details for
Bug 236962
[JAVA_BLOCKER] rtcheck on RHEL5 RT
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
rtcheck.c testcase
rtcheck.c (text/plain), 6.59 KB, created by
IBM Bug Proxy
on 2007-04-18 17:39:43 UTC
(
hide
)
Description:
rtcheck.c testcase
Filename:
MIME Type:
Creator:
IBM Bug Proxy
Created:
2007-04-18 17:39:43 UTC
Size:
6.59 KB
patch
obsolete
>/* > * rt_check.c -- Check to see if the appropriate features are present > * for Real-Time Java to function correctly. > * > * Returns 0 on success, and non-zero on failure. The failure will indicate > * what necessary feature was not present > * > * 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; version 2 of the License. > * > * 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. > * > * Copyright 2006 by IBM, All Rights Reserved > * > * Author(s): > * Theodore Ts'o > * Timothy R. Chavez <tinytim@us.ibm.com> > * > * Changelog: > * 05/08/2006 - Added test_clockres to test whether or not clock > * resolution is within the acceptable range (<= 200us) for the JVM. > */ > >#include <unistd.h> >#include <stdlib.h> >#include <stdio.h> >#include <errno.h> >#include <string.h> >#include <sched.h> >#include <dlfcn.h> >#include <time.h> >#include <sys/time.h> >#include <sys/mman.h> >#include <sys/resource.h> >#include <sys/utsname.h> > >#define FAIL_MEMLOCK 0x0001 >#define FAIL_SCHED 0x0002 >#define FAIL_KTIMER 0x0004 >#define FAIL_ROBUST_MUTEX 0x0008 /* Could be ROBUST FUTEX? */ >#define FAIL_KERNEL_RELEASE 0x0010 >#define FAIL_CLOCK_RES 0x0020 > >#define OPT_VERBOSE 0x0001 > >#define FAIL_MSG "failed\n\t" > >static void usage(char *progname) >{ > fprintf(stderr, "Usage: %s [-v]\n", progname); > exit(1); >} > >/* > * Utility routine that tests for a set of symbols > */ >static int test_symbols(char *syms[], int flags) >{ > void *handle; > char *sym; > int failed = 0; > > handle = dlopen(NULL, RTLD_NOW); > > for (; (sym = *syms); syms++) { > if (flags & OPT_VERBOSE) > printf("\tChecking for %s: ", sym); > if (dlsym(handle, sym)) { > if (flags & OPT_VERBOSE) > printf("ok\n"); > } else { > if (flags & OPT_VERBOSE) > printf("failed\n"); > failed++; > } > } > > dlclose(handle); > return failed; >} > >static int test_sched(int flags) >{ > struct sched_param param, new_param; > int policy, new_policy; > > if (flags & OPT_VERBOSE) > printf("trying to request real-time scheduling: "); > > policy = sched_getscheduler(0); > > if (sched_getparam(0, ¶m) < 0) { > perror("sched_getparam"); > return FAIL_SCHED; > } > > new_param = param; > new_policy = SCHED_RR; > new_param.sched_priority = sched_get_priority_max(new_policy); > > if (sched_setscheduler(0, new_policy, &new_param) < 0) { > if (flags & OPT_VERBOSE) > printf(FAIL_MSG "sched_setscheduler: %s\n", > strerror(errno)); > return FAIL_SCHED; > } > > if (sched_setscheduler(0, policy, ¶m) < 0) { > if (flags & OPT_VERBOSE) > printf(FAIL_MSG "resetting original scheduler: %s\n", > strerror(errno)); > return FAIL_SCHED; > } > > if (flags & OPT_VERBOSE) > printf("ok\n"); > > return 0; >} > >#define TEST_LEN 32768 > >static int test_memlock(int flags) >{ > static char test_buffer[TEST_LEN]; > struct rlimit rlim; > int page_size, len; > char *ptr; > > if (flags & OPT_VERBOSE) > printf("trying to lock memory: "); > > page_size = sysconf(_SC_PAGESIZE); > > /* > * Make sure the pointer is page aligned and the length is a multiple > * of a page size. Not strictly required by Linux, but some OS's may > * require this. > */ > ptr = (char *) ((unsigned long) test_buffer & ~(page_size-1)); > len = (TEST_LEN - (test_buffer - ptr)) & ~(page_size-1); > > if (mlock(ptr, len) < 0) { > if (flags & OPT_VERBOSE) > printf(FAIL_MSG "mlock: %s\n", strerror(errno)); > return FAIL_MEMLOCK; > } > > if (munlock(ptr, len) < 0) { > if (flags & OPT_VERBOSE) > printf(FAIL_MSG "munlock: %s\n", strerror(errno)); > return FAIL_MEMLOCK; > } > > if (getrlimit(RLIMIT_MEMLOCK, &rlim) < 0) { > if (flags & OPT_VERBOSE) > printf(FAIL_MSG "getrlimit: %s\n", strerror(errno)); > return FAIL_MEMLOCK; > } > > if (rlim.rlim_cur != RLIM_INFINITY) { > if (flags & OPT_VERBOSE) > printf(FAIL_MSG "RLIMIT_MLOCK is %u\n", > (unsigned int) rlim.rlim_cur); > return FAIL_MEMLOCK; > } > > if (flags & OPT_VERBOSE) > printf("ok\n"); > > return 0; >} > >static int test_ktimer(int flags) >{ > if (flags & OPT_VERBOSE) > printf("testing for high resolution timers: "); > > if (flags & OPT_VERBOSE) > printf("ok (not yet implemented)\n"); > return 0; >} > >static int test_robust_mutex(int flags) >{ > static char *syms[] = { "pthread_mutex_init", /* placebo test */ > "pthread_mutexattr_getprotocol", > "pthread_mutexattr_setprotocol", > /* add other required symbols */ > 0 }; > int failed; > > if (flags & OPT_VERBOSE) > printf("testing for robust (PI) mutexes: "); > > if ((failed = test_symbols(syms, 0)) != 0) { > if (flags & OPT_VERBOSE) { > printf(FAIL_MSG > "failed to find all required symbols.\n"); > test_symbols(syms, flags); > } > return FAIL_ROBUST_MUTEX; > } > > /* n.b. we need to test both glibc and kernel-level support! */ > > if (flags & OPT_VERBOSE) > printf("ok (not yet fully implemented)\n"); > return 0; >} > >static int test_rtj12(int flags) >{ > int ret; > struct utsname uts; > > if (flags & OPT_VERBOSE) > printf("testing for the rtj12 kernel: "); > > if (uname(&uts) != 0) { > if (flags & OPT_VERBOSE) { > perror("function test_rtj12, uname"); > } > return FAIL_KERNEL_RELEASE; > } > > ret = (strstr(uts.release, "rtj12") != NULL) ? 0 : FAIL_KERNEL_RELEASE; > > if (flags & OPT_VERBOSE) { > if (!ret) > printf("ok.\n"); > else > printf("failed.\n"); > } > > return ret; >} > >int test_clockres(int flags) >{ > int ret; > struct timespec ts; > > if (clock_getres(CLOCK_REALTIME, &ts) < 0) { > perror("clock_getres"); > return errno; > } > > ret = (ts.tv_sec == 0 && ts.tv_nsec <= 200000) ? 0 : FAIL_CLOCK_RES; > > if (flags & OPT_VERBOSE) { > printf("testing for acceptable clock resolution (<=200us): "); > > if (!ret) > printf("ok."); > else > printf("failed."); > } > > return ret; >} > >int main(int argc, char **argv) >{ > int c; > int flags = 0; > int ret = 0; > > while ((c = getopt (argc, argv, "v")) != EOF) { > switch (c) { > case 'v': > flags |= OPT_VERBOSE; > break; > default: > usage(argv[0]); > } > } > if (optind > argc) > usage(argv[0]); > > ret |= test_sched(flags); > ret |= test_memlock(flags); > ret |= test_ktimer(flags); > ret |= test_robust_mutex(flags); > ret |= test_rtj12(flags); > ret |= test_clockres(flags); > > if (flags & OPT_VERBOSE) { > if (ret) > printf("\nSome tests failed, exiting with " > "status %d\n", ret); > else > printf("\nAll tests passed; RT Java will be " > "permitted to run\n"); > } > > exit(ret); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 236962
: 152932 |
154753
|
155906
|
156473
|
156511
|
156512