Issues (1963)

html/user/submit_test.php (1 issue)

1
<?php
2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2018 University of California
5
//
6
// BOINC is free software; you can redistribute it and/or modify it
7
// under the terms of the GNU Lesser General Public License
8
// as published by the Free Software Foundation,
9
// either version 3 of the License, or (at your option) any later version.
10
//
11
// BOINC is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
// See the GNU Lesser General Public License for more details.
15
//
16
// You should have received a copy of the GNU Lesser General Public License
17
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
19
// tests for remote job submission interfaces
20
//
21
// you must have a file "config.txt":
22
// line 0: project URL
23
// line 1: authenticator
24
//
25
// you must run this in a dir with a copy of or link to html/inc/submit.inc
26
27
// TODO: add more tests
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
28
29
require_once("submit.inc");
30
31
// for this test, you must have
32
// - an app "uppercase"
33
// - templates uppercase_in and uppercase_out
34
// - a staged file "input"
35
//
36
function test_submit_batch($req) {
37
    $req->app_name = "uppercase";
38
    $req->jobs = array();
39
40
    $f = new StdClass;
41
    $f->mode = "local_staged";
42
    $f->source = "input";
43
44
    for ($i=10; $i<20; $i++) {
45
        $job = new StdClass;
46
        $job->input_files = array($f);
47
        $job->rsc_fpops_est = $i*1e9;
48
        $job->command_line = "--t $i";
49
        $req->jobs[] = $job;
50
    }
51
52
    list($batch_id, $errmsg) = boinc_submit_batch($req);
53
    if ($errmsg) {
54
        echo "Error: $errmsg\n";
55
    } else {
56
        echo "Batch ID: $batch_id\n";
57
    }
58
}
59
60
function test_query_batch($req, $id) {
61
    $req->batch_id = $id;
62
    $req->get_cpu_time = true;
63
    list($r, $errmsg) = boinc_query_batch($req);
64
    if ($errmsg) {
65
        echo "Error: $errmsg\n";
66
    } else {
67
        print_r($r);
68
    }
69
}
70
71
$config = file("config.txt");
72
$project = trim($config[0]);
73
$auth = trim($config[1]);
74
75
$req = new StdClass;
76
$req->project = $project;
77
$req->authenticator = $auth;
78
79
//test_submit_batch($req);
80
test_query_batch($req, 267);
81