~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/japi/test_drmaa_no_bin.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include "drmaa.h"
 
4
 
 
5
#define WD "/tmp"
 
6
 
 
7
int handle_code(int code, char *msg);
 
8
 
 
9
int main(int argc, char **argv) {
 
10
    int ret = DRMAA_ERRNO_SUCCESS;
 
11
    char error[DRMAA_ERROR_STRING_BUFFER + 1];
 
12
    drmaa_job_template_t *jt = NULL;
 
13
    char jobid[DRMAA_JOBNAME_BUFFER + 1];
 
14
 
 
15
    if (argc != 2) {
 
16
       printf("Usage: %s path_to_script\n", argv[0]);
 
17
       exit(1);
 
18
    }
 
19
    
 
20
    ret = drmaa_init("", error, DRMAA_ERROR_STRING_BUFFER);
 
21
    if (handle_code(ret, error) == 1) {
 
22
        exit(1);
 
23
    }
 
24
    
 
25
    ret = drmaa_allocate_job_template(&jt, error, DRMAA_ERROR_STRING_BUFFER);
 
26
    if (handle_code(ret, error) == 1) {
 
27
        return 1;
 
28
    }
 
29
    
 
30
    ret = drmaa_set_attribute(jt, DRMAA_REMOTE_COMMAND, argv[1], error,
 
31
    DRMAA_ERROR_STRING_BUFFER);
 
32
    if (handle_code(ret, error) == 1) {
 
33
        return 1;
 
34
    }
 
35
    
 
36
    ret = drmaa_set_attribute(jt, DRMAA_WD, WD, error,
 
37
    DRMAA_ERROR_STRING_BUFFER);
 
38
    if (handle_code(ret, error) == 1) {
 
39
        return 1;
 
40
    }
 
41
    
 
42
    ret = drmaa_set_attribute(jt, DRMAA_NATIVE_SPECIFICATION, "-b n -cwd", error,
 
43
    DRMAA_ERROR_STRING_BUFFER);
 
44
    if (handle_code(ret, error) == 1) {
 
45
        return 1;
 
46
    }
 
47
    
 
48
    ret = drmaa_run_job(jobid, DRMAA_JOBNAME_BUFFER, jt, error,
 
49
    DRMAA_ERROR_STRING_BUFFER);
 
50
    if (handle_code(ret, error) == 1) {
 
51
        return 1;
 
52
    }
 
53
    
 
54
    ret = drmaa_exit(error, DRMAA_ERROR_STRING_BUFFER);
 
55
    handle_code(ret, error);
 
56
    
 
57
    printf ("OK\n");
 
58
    
 
59
    return 0;
 
60
}
 
61
 
 
62
int handle_code(int code, char *msg) {
 
63
    if (code != DRMAA_ERRNO_SUCCESS) {
 
64
        printf("EXCEPTION: %s\n", msg);
 
65
        return 1;
 
66
    }
 
67
    else {
 
68
        return 0;
 
69
    }
 
70
}