1- #define CATCH_CONFIG_MAIN
1+ #define CATCH_CONFIG_MAIN
22
33#include < catch2/catch_test_macros.hpp>
44#include < resource/reapi/bindings/c++/reapi_cli.hpp>
55#include < fstream>
66
77namespace Flux ::resource_model::detail {
88
9- TEST_CASE ( " Initialize REAPI CLI" , " [initialize C++]" ) {
9+ TEST_CASE (" Initialize REAPI CLI" , " [initialize C++]" )
10+ {
1011 const std::string options = " {}" ;
1112 std::stringstream buffer;
1213 std::ifstream inputFile (" ../../../t/data/resource/jgfs/tiny.json" );
@@ -23,7 +24,8 @@ TEST_CASE( "Initialize REAPI CLI", "[initialize C++]" ) {
2324 REQUIRE (ctx);
2425}
2526
26- TEST_CASE ( " Match basic jobspec" , " [match grow C++]" ) {
27+ TEST_CASE (" Match and basic jobspec" , " [match grow C++]" )
28+ {
2729 int rc = -1 ;
2830 const std::string options = " {}" ;
2931 std::stringstream gbuffer, jbuffer;
@@ -55,20 +57,89 @@ TEST_CASE( "Match basic jobspec", "[match grow C++]" ) {
5557 double ov = 0.0 ;
5658 int64_t at = 0 ;
5759
58- rc = detail::reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
60+ rc = detail::reapi_cli_t::match_allocate (ctx.get (),
61+ match_op,
62+ jobspec,
63+ jobid,
64+ reserved,
65+ R,
66+ at,
67+ ov);
5968 REQUIRE (rc == 0 );
6069 REQUIRE (reserved == false );
6170 REQUIRE (at == 0 );
6271
6372 R = " " ;
6473 match_op = match_op_t ::MATCH_GROW_ALLOCATION;
65- rc = detail::reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
74+ rc = detail::reapi_cli_t::match_allocate (ctx.get (),
75+ match_op,
76+ jobspec,
77+ jobid,
78+ reserved,
79+ R,
80+ at,
81+ ov);
6682 REQUIRE (rc == 0 );
6783 REQUIRE (reserved == false );
6884 REQUIRE (at == 0 );
6985}
7086
71- }
87+ TEST_CASE (" Match shrink basic jobspec" , " [match shrink C++]" )
88+ {
89+ int rc = -1 ;
90+ const std::string options = " {\" load_format\" : \" rv1exec\" }" ;
91+ std::stringstream gbuffer, jbuffer, cbuffer;
92+ std::ifstream graphfile (" ../../../t/data/resource/rv1exec/tiny_rv1exec.json" );
93+ std::ifstream jobspecfile (" ../../../t/data/resource/jobspecs/cancel/test018.yaml" );
94+ std::ifstream cancelfile (" ../../../t/data/resource/rv1exec/cancel/rank1_cancel.json" );
95+
96+ if (!graphfile.is_open ()) {
97+ std::cerr << " Error opening file!" << std::endl;
98+ }
99+
100+ if (!jobspecfile.is_open ()) {
101+ std::cerr << " Error opening file!" << std::endl;
102+ }
103+
104+ if (!cancelfile.is_open ()) {
105+ std::cerr << " Error opening file!" << std::endl;
106+ }
107+
108+ gbuffer << graphfile.rdbuf ();
109+ std::string rgraph = gbuffer.str ();
110+ jbuffer << jobspecfile.rdbuf ();
111+ std::string jobspec = jbuffer.str ();
112+ cbuffer << cancelfile.rdbuf ();
113+ std::string cancel_string = cbuffer.str ();
72114
115+ std::shared_ptr<resource_query_t > ctx = nullptr ;
116+ ctx = std::make_shared<resource_query_t > (rgraph, options);
117+ REQUIRE (ctx);
73118
119+ match_op_t match_op = match_op_t ::MATCH_ALLOCATE;
120+ bool reserved = false ;
121+ std::string R = " " ;
122+ uint64_t jobid = 1 ;
123+ double ov = 0.0 ;
124+ int64_t at = 0 ;
125+
126+ rc = detail::reapi_cli_t::match_allocate (ctx.get (),
127+ match_op,
128+ jobspec,
129+ jobid,
130+ reserved,
131+ R,
132+ at,
133+ ov);
134+ REQUIRE (rc == 0 );
135+ REQUIRE (reserved == false );
136+ REQUIRE (at == 0 );
137+
138+ bool noent_ok = false ;
139+ bool full_removal = true ;
140+ rc = detail::reapi_cli_t::cancel (ctx.get (), jobid, cancel_string, noent_ok, full_removal);
141+ REQUIRE (rc == 0 );
142+ REQUIRE (full_removal == false );
143+ }
74144
145+ } // namespace Flux::resource_model::detail
0 commit comments