1
1

Add a few test functions transferred from ORTE trunk

This commit was SVN r14467.
Этот коммит содержится в:
Ralph Castain 2007-04-23 14:43:55 +00:00
родитель f47e7382e3
Коммит 477828159e
3 изменённых файлов: 84 добавлений и 1 удалений

Просмотреть файл

@ -1,4 +1,4 @@
PROGS = no_op sigusr_trap spin orte_nodename orte_proc_subscribe orte_stage_gate orte_spawn orte_loop_spawn orte_loop_child
PROGS = no_op sigusr_trap spin orte_nodename orte_proc_subscribe orte_stage_gate orte_spawn orte_loop_spawn orte_loop_child orte_abort get_limits
all: $(PROGS)

40
orte/test/system/get_limits.c Обычный файл
Просмотреть файл

@ -0,0 +1,40 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <sys/resource.h>
int main(int argc, char* argv[])
{
int i = 0;
pid_t pid;
struct rlimit rlim;
if (getrlimit (RLIMIT_NOFILE, &rlim) < 0)
fprintf (stderr, "getrlimit (RLIMIT_NOFILE): %s\n", strerror (errno));
else {
printf("softlimit on num_files: %d\thardlimit on num_files: %d\n", rlim.rlim_cur, rlim.rlim_max);
}
if (getrlimit (RLIMIT_NPROC, &rlim) < 0)
fprintf (stderr, "getrlimit (RLIMIT_NPROC): %s\n", strerror (errno));
else {
printf("softlimit on num_child: %d\thardlimit on num_child: %d\n", rlim.rlim_cur, rlim.rlim_max);
}
printf("RLIM_INFINITY: %d\n", RLIM_INFINITY);
return 0;
}
#if 0
int nfds_needed = calculate_nfds_needed (nprocs);
if (nfds_needed > rlim->rlim_cur) {
if (nfds_needed <= rlim->rlim_max)
rlim->rlim_cur = rlim->rlim_max;
if (setrlimit (RLIMIT_NOFILE, rlim) < 0)
fprintf (stderr, "setrlimit (RLIMIT_NOFILE, cur = %d): %m\n";
else
fprintf (stderr, "Hard limit for number of open files is too low\n");
}
#endif

43
orte/test/system/orte_abort.c Обычный файл
Просмотреть файл

@ -0,0 +1,43 @@
/* -*- C -*-
*
* $HEADER$
*
* A program that just spins, with vpid 3 aborting - provides mechanism for testing
* abnormal program termination
*/
#include <stdio.h>
#include <unistd.h>
#include "orte/util/proc_info.h"
int main(int argc, char* argv[])
{
int i, rc;
double pi;
pid_t pid;
char hostname[500];
if (0 > (rc = orte_init())) {
fprintf(stderr, "orte_abort: couldn't init orte - error code %d\n", rc);
return rc;
}
pid = getpid();
gethostname(hostname, 500);
printf("orte_abort: Name [%lu,%lu,%lu] Host: %s Pid %ld\n", ORTE_NAME_ARGS(orte_process_info.my_name),
hostname, (long)pid);
i = 0;
while (1) {
i++;
pi = i / 3.14159256;
if (i > 10000) i = 0;
if (orte_process_info.my_name->vpid == 3 && i == 9995) {
orte_abort(1, true);
}
}
return 0;
}