From bdf2a3cc3b31ef44a2a633904b5a76a43d147716 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Fri, 21 Aug 2009 21:33:06 +0000
Subject: [PATCH] add _test_only function, no real change in logic

---
 src/plugins/select/cons_res/select_cons_res.c | 25 ++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index 9012dcb6a14..3e957ea4dc6 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -184,6 +184,8 @@ extern select_nodeinfo_t *select_p_select_nodeinfo_alloc(uint32_t size);
 extern int select_p_select_nodeinfo_free(select_nodeinfo_t *nodeinfo);
 
 /* Procedure Declarations */
+static int _test_only(struct job_record *job_ptr, bitstr_t *bitmap,
+		      uint32_t min_nodes, uint32_t max_nodes,   		      uint32_t req_nodes, uint16_t job_node_req);
 static int _will_run_test(struct job_record *job_ptr, bitstr_t *bitmap,
 			uint32_t min_nodes, uint32_t max_nodes, 
 			uint32_t req_nodes, uint16_t job_node_req);
@@ -1103,6 +1105,19 @@ static bool _is_preemptable(struct job_record *job_ptr,
 	return false;
 }
 
+/* Determine if a job can ever run */
+static int _test_only(struct job_record *job_ptr, bitstr_t *bitmap,
+		      uint32_t min_nodes, uint32_t max_nodes,   		      uint32_t req_nodes, uint16_t job_node_req)
+{
+	int rc;
+
+	rc = cr_job_test(job_ptr, bitmap, min_nodes, max_nodes, req_nodes, 
+			 SELECT_MODE_TEST_ONLY, cr_type, job_node_req,
+			 select_node_cnt, select_part_record, 
+			 select_node_usage);
+	return rc;
+}
+
 /* _will_run_test - determine when and where a pending job can start, removes 
  *	jobs from node table at termination time and run _test_job() after 
  *	each one. Used by SLURM's sched/backfill plugin and Moab. */
@@ -1498,7 +1513,7 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 			     uint32_t min_nodes, uint32_t max_nodes, 
 			     uint32_t req_nodes, int mode)
 {
-	int rc;
+	int rc = EINVAL;
 	uint16_t job_node_req;
 	bool debug_cpu_bind = false, debug_check = false;
 
@@ -1528,12 +1543,16 @@ extern int select_p_job_test(struct job_record *job_ptr, bitstr_t * bitmap,
 	if (mode == SELECT_MODE_WILL_RUN) {
 		rc = _will_run_test(job_ptr, bitmap, min_nodes, max_nodes,
 				    req_nodes, job_node_req);
-	} else {
+	} else if (mode == SELECT_MODE_TEST_ONLY) {
+		rc = _test_only(job_ptr, bitmap, min_nodes, max_nodes,
+				req_nodes, job_node_req);
+	} else if (mode == SELECT_MODE_RUN_NOW) {
 		rc = cr_job_test(job_ptr, bitmap, min_nodes, max_nodes,
 				 req_nodes, mode, cr_type, job_node_req,
 				 select_node_cnt, select_part_record,
 				 select_node_usage);
-	}
+	} else
+		fatal("select_p_job_test: Mode %d is invalid", mode);
 
 #if (CR_DEBUG)
 	if (job_ptr->select_job)
-- 
GitLab