You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/db/init.sql

5542 lines
192 KiB

SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `repertoires`;
CREATE TABLE `repertoires` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
insert into `repertoires`(`id`,`name`,`created_at`,`updated_at`) values
(1,'前端开发','2018-02-08 15:12:08','2018-05-11 17:14:07'),
(2,'后端开发','2018-02-08 15:12:17','2018-05-11 17:14:04'),
(3,'移动开发','2018-02-08 15:12:24','2018-05-11 17:14:03'),
(4,'数据库','2018-02-08 15:12:28','2018-05-11 17:14:01'),
(5,'云计算和大数据','2018-02-08 15:12:39','2018-05-11 17:13:59'),
(6,'运维与测试','2018-02-08 15:12:46','2018-05-11 17:13:56'),
(8,'其它','2018-02-08 15:13:03','2018-05-11 17:13:42'),
(9,'人工智能','2018-04-13 17:36:23','2018-05-11 17:13:54');
DROP TABLE IF EXISTS `sub_repertoires`;
CREATE TABLE `sub_repertoires` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`repertoire_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `index_sub_repertoires_on_repertoire_id` (`repertoire_id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;
insert into `sub_repertoires`(`id`,`name`,`repertoire_id`,`created_at`,`updated_at`) values
(1,'前端基础',1,'2018-02-08 15:13:18','2018-05-11 17:14:34'),
(3,'前端框架',1,'2018-02-08 15:13:29','2018-05-11 17:14:32'),
(5,'应用开发',3,'2018-02-08 15:13:59','2018-02-08 15:13:59'),
(9,'SQL',4,'2018-02-08 15:14:24','2018-02-08 15:14:24'),
(13,'云计算',5,'2018-02-08 15:14:58','2018-05-11 17:14:40'),
(14,'大数据',5,'2018-02-08 15:15:02','2018-05-11 17:14:42'),
(16,'Linux运维',6,'2018-02-08 15:15:14','2018-05-11 17:14:44'),
(17,'网络',6,'2018-02-08 15:15:26','2018-05-11 17:14:45'),
(18,'测试工具',6,'2018-02-08 15:15:32','2018-05-11 17:14:47'),
(19,'计算机课程',8,'2018-02-08 15:15:46','2018-02-08 15:15:46'),
(20,'Python',2,'2018-04-08 10:55:28','2018-05-11 17:13:07'),
(21,'PHP',2,'2018-04-08 10:56:13','2018-05-11 17:13:02'),
(22,'Java',2,'2018-04-08 11:02:55','2018-05-11 17:13:09'),
(23,'Ruby',2,'2018-04-08 11:03:52','2018-05-11 17:12:59'),
(24,'ASP.NET',2,'2018-04-08 11:04:27','2018-05-11 17:12:30'),
(25,'Go',2,'2018-04-08 11:05:11','2018-05-11 17:13:00'),
(26,'更多',2,'2018-04-08 11:06:46','2018-05-11 17:12:27'),
(27,'人工智能',9,'2018-04-13 17:36:23','2018-04-13 17:39:53'),
(29,'C',2,'2018-05-11 09:23:14','2018-05-11 17:13:06'),
(30,'C++',2,'2018-05-11 09:28:02','2018-05-11 17:13:04');
DROP TABLE IF EXISTS `tag_repertoires`;
CREATE TABLE `tag_repertoires` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`sub_repertoire_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=168 DEFAULT CHARSET=utf8;
insert into `tag_repertoires`(`id`,`name`,`sub_repertoire_id`,`created_at`,`updated_at`) values
(1,'HTML',1,'2018-04-08 10:18:27','2018-05-11 17:15:11'),
(2,'CSS',1,'2018-04-08 10:18:33','2018-05-11 17:15:09'),
(3,'Html5',1,'2018-04-08 10:18:39','2018-05-11 17:15:08'),
(4,'CSS3',1,'2018-04-08 10:18:45','2018-05-11 17:15:06'),
(5,'JavaScript',1,'2018-04-08 10:18:50','2019-02-22 09:35:30'),
(10,'Bootstrap',3,'2018-04-08 10:19:22','2018-04-08 10:19:22'),
(13,'AngularJS',3,'2018-04-08 10:30:47','2018-04-08 10:30:47'),
(14,'Aurelia',3,'2018-04-08 10:30:58','2018-04-08 10:30:58'),
(15,'Backbone',3,'2018-04-08 10:31:10','2018-04-08 10:31:10'),
(16,'d3.js',3,'2018-04-08 10:31:17','2018-04-08 10:31:17'),
(18,'Dojo 2',3,'2018-04-08 10:31:58','2018-04-08 10:31:58'),
(20,'Ember.js',3,'2018-04-08 10:40:36','2018-04-08 10:40:36'),
(21,'Ext JS',3,'2018-04-08 10:40:43','2018-04-08 10:40:43'),
(23,'Gulp',3,'2018-04-08 10:50:20','2018-04-08 10:50:20'),
(24,'Ionic',3,'2018-04-08 10:50:25','2018-04-08 10:50:25'),
(26,'Knockout',3,'2018-04-08 10:50:38','2018-04-08 10:50:38'),
(27,'MDLMaterial Design Lite',3,'2018-04-08 10:50:54','2018-04-08 10:50:54'),
(28,'MooTools',3,'2018-04-08 10:50:59','2018-04-08 10:50:59'),
(30,'Rails',3,'2018-04-08 10:51:11','2018-04-08 10:51:11'),
(31,'React.JS',3,'2018-04-08 10:51:18','2018-04-08 10:51:18'),
(32,'ReactNative',3,'2018-04-08 10:51:26','2018-04-08 10:51:26'),
(33,'redux',3,'2018-04-08 10:51:32','2018-04-08 10:51:32'),
(34,'RxJS',3,'2018-04-08 10:51:36','2018-04-08 10:51:36'),
(35,'Less',3,'2018-04-08 10:51:40','2018-04-08 10:51:40'),
(36,'Sass',3,'2018-04-08 10:51:44','2018-04-08 10:51:44'),
(37,'Underscore',3,'2018-04-08 10:51:50','2018-04-08 10:51:50'),
(38,'Vue.js',3,'2018-04-08 10:51:54','2018-04-08 10:51:54'),
(39,'Hogan.js',3,'2018-04-08 10:51:59','2018-04-08 10:51:59'),
(40,'Zebra',3,'2018-04-08 10:52:06','2018-04-08 10:52:06'),
(43,'Meteor',3,'2018-04-08 10:52:30','2018-04-08 10:52:30'),
(46,'Python基础',20,'2018-04-08 10:55:46','2018-05-15 14:55:30'),
(47,'web2py',20,'2018-04-08 10:55:50','2018-05-15 14:55:27'),
(48,'Django',20,'2018-04-08 10:55:55','2018-05-15 14:55:26'),
(49,'Flask',20,'2018-04-08 10:56:00','2018-05-15 14:55:25'),
(50,'数据挖掘与分析',20,'2018-04-08 10:56:05','2018-05-15 14:55:24'),
(51,'PHP基础',21,'2018-04-08 10:56:20','2018-05-11 17:19:00'),
(52,'ThinkPHP',21,'2018-04-08 10:56:25','2018-05-11 17:18:59'),
(53,'Laravel',21,'2018-04-08 10:56:29','2018-05-11 17:18:58'),
(54,'WordPress',21,'2018-04-08 10:56:34','2018-05-11 17:18:57'),
(56,'Java基础',22,'2018-04-08 11:03:09','2018-05-11 17:19:25'),
(57,'JSP',22,'2018-04-08 11:03:14','2018-05-11 17:19:24'),
(59,'Spring',22,'2018-04-08 11:03:23','2018-05-11 17:19:23'),
(60,'Struts2',22,'2018-04-08 11:03:28','2018-05-11 17:19:22'),
(61,'MyBatis',22,'2018-04-08 11:03:33','2018-05-11 17:19:21'),
(62,'Hibernate',22,'2018-04-08 11:03:37','2018-05-11 17:19:20'),
(63,'Lucene',22,'2018-04-08 11:03:42','2018-05-11 17:19:19'),
(64,'Ruby基础',23,'2018-04-08 11:03:58','2018-05-11 17:19:07'),
(65,'Ruby on Rails',23,'2018-04-08 11:04:04','2018-05-11 17:19:06'),
(66,'Grape',23,'2018-04-08 11:04:09','2018-05-11 17:19:05'),
(67,'Ruby进阶',23,'2018-04-08 11:04:13','2018-05-11 17:19:04'),
(68,'RubyMine',23,'2018-04-08 11:04:18','2018-05-11 17:19:03'),
(69,'C#',24,'2018-04-08 11:04:43','2018-04-08 11:04:43'),
(70,'ASP.NET MVC',24,'2018-04-08 11:04:47','2018-04-08 11:04:47'),
(71,'Entity Framework',24,'2018-04-08 11:04:55','2018-04-08 11:04:55'),
(72,'WPF',24,'2018-04-08 11:05:00','2018-04-08 11:05:00'),
(73,'Go基础',25,'2018-04-08 11:05:21','2018-04-08 11:05:21'),
(78,'R',26,'2018-04-08 11:07:03','2018-04-08 11:07:03'),
(79,'Perl',26,'2018-04-08 11:07:09','2018-04-08 11:07:09'),
(80,'YAML',26,'2018-04-08 11:07:17','2018-04-08 11:07:17'),
(82,'Kotlin',26,'2018-04-08 11:07:28','2018-04-08 11:07:28'),
(86,'Android',5,'2018-04-08 11:07:57','2018-05-11 17:19:12'),
(87,'IOS',5,'2018-04-08 11:08:03','2018-05-11 17:19:11'),
(88,'MySQL',9,'2018-04-08 11:08:23','2018-05-21 09:16:30'),
(89,'SQL Server',9,'2018-04-08 11:08:28','2019-08-28 16:58:13'),
(90,'Oracle',9,'2018-04-08 11:08:32','2018-05-21 09:16:27'),
(91,'SQLite',9,'2018-04-08 11:08:36','2018-05-21 09:16:26'),
(92,'PostgreSQL',9,'2018-04-08 11:08:41','2018-05-21 09:16:25'),
(93,'DB2',9,'2018-04-08 11:08:45','2018-05-21 09:16:24'),
(102,'OpenStack',13,'2018-04-08 11:10:15','2018-04-08 11:10:15'),
(103,'Docker',13,'2018-04-08 11:10:20','2018-04-08 11:10:20'),
(104,'Hadoop',14,'2018-04-08 11:10:28','2018-06-22 13:23:49'),
(105,'Spark',14,'2018-04-08 11:10:32','2018-06-22 13:23:48'),
(106,'Hive',14,'2018-04-08 11:10:36','2018-06-22 13:23:47'),
(107,'Kafka',14,'2018-04-08 11:10:40','2018-06-22 13:23:45'),
(108,'Zookeeper',14,'2018-04-08 11:10:45','2018-06-22 13:23:46'),
(109,'Hbase',14,'2018-04-08 11:10:49','2018-06-22 13:23:43'),
(110,'Mahout',14,'2018-04-08 11:10:54','2018-06-22 13:23:42'),
(111,'Scala',14,'2018-04-08 11:10:59','2018-06-22 13:23:41'),
(112,'SDN',14,'2018-04-08 11:11:09','2018-06-22 13:23:40'),
(113,'Elasticsearch',14,'2018-04-08 11:11:15','2018-06-22 13:23:39'),
(114,'Linux',16,'2018-04-08 11:11:35','2018-04-08 11:11:35'),
(115,'Shell',16,'2018-04-08 11:11:39','2018-04-08 11:11:39'),
(116,'Nginx',16,'2018-04-08 11:11:47','2018-04-08 11:11:47'),
(117,'Ansible',16,'2018-04-08 11:11:51','2018-04-08 11:11:51'),
(118,'Git',16,'2018-04-08 11:11:55','2018-04-08 11:11:55'),
(119,'Dynamips',17,'2018-04-08 11:12:00','2018-04-08 11:12:00'),
(120,'VNC',17,'2018-04-08 11:12:05','2018-04-08 11:12:05'),
(121,'Socket.io',17,'2018-04-08 11:12:09','2018-04-08 11:12:09'),
(122,'Jmeter',18,'2018-04-08 11:12:15','2018-04-08 11:12:15'),
(123,'Check',18,'2018-04-08 11:12:21','2018-04-08 11:12:21'),
(124,'CPPUnit',18,'2018-04-08 11:12:24','2018-04-08 11:12:24'),
(125,'CUnit',18,'2018-04-08 11:12:28','2018-04-08 11:12:28'),
(126,'CuTest',18,'2018-04-08 11:12:32','2018-04-08 11:12:32'),
(127,'Junit',18,'2018-04-08 11:12:37','2018-04-08 11:12:37'),
(128,'Mocha',18,'2018-04-08 11:12:41','2018-04-08 11:12:41'),
(129,'Rspec',18,'2018-04-08 11:12:45','2018-04-08 11:12:45'),
(130,'Selenium',18,'2018-04-08 11:12:49','2018-04-08 11:12:49'),
(131,'unittest',18,'2018-04-08 11:12:53','2018-04-08 11:12:53'),
(132,'Watir',18,'2018-04-08 11:12:59','2018-04-08 11:12:59'),
(133,'Verilog',19,'2018-04-08 11:14:12','2018-05-11 17:16:02'),
(134,'Matlab',19,'2018-04-08 11:14:17','2018-05-11 17:16:01'),
(135,'VHDL',19,'2018-04-13 16:29:29','2018-05-11 17:15:59'),
(136,'Jfinal',22,'2018-04-13 16:41:56','2018-05-11 17:19:18'),
(142,'机器学习',27,'2018-04-13 17:39:32','2018-05-16 14:14:06'),
(144,'深度学习',27,'2018-04-13 17:40:04','2018-05-16 14:14:04'),
(145,'信号与系统',19,'2018-04-17 11:34:29','2018-05-11 17:15:58'),
(146,'大学计算机基础',19,'2018-05-08 17:15:48','2018-05-11 17:15:57'),
(148,'其它',19,'2018-05-11 08:34:57','2018-05-11 17:15:56'),
(151,'jQuery',1,'2018-05-11 09:20:15','2018-05-11 17:15:04'),
(152,'C语言基础',29,'2018-05-11 09:26:55','2018-05-11 09:27:23'),
(160,'C++基础',30,'2018-05-11 09:28:17','2018-05-11 17:18:55'),
(161,'C++图像处理',30,'2018-05-11 11:07:29','2018-05-11 17:18:53'),
(162,'Node.js',3,'2018-05-11 11:11:22','2018-05-11 11:11:22'),
(163,'MongoDB',9,'2018-05-11 11:17:36','2018-08-27 08:43:34'),
(164,'Redis',9,'2018-05-11 11:17:58','2018-05-21 09:16:21'),
(165,'汇编',26,'2019-02-21 13:56:34','2019-02-21 13:56:34'),
(166,'Flink',14,'2019-06-18 08:13:38','2019-06-18 08:13:38'),
(167,'图形化工具',19,'2019-07-23 15:36:36','2019-07-23 15:36:36');
DROP TABLE IF EXISTS `portal_images`;
CREATE TABLE `portal_images` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`position` int(11) DEFAULT NULL,
`link` varchar(255) DEFAULT NULL,
`status` tinyint(1) DEFAULT '0',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
insert into `portal_images`(`id`,`name`,`position`,`link`,`status`,`created_at`,`updated_at`) values
(1,'云启校园计划',1,'https://ecloud.10086.cn/market/marketStu',0,'2018-08-24 14:21:53','2019-06-29 20:13:05'),
(3,'CCF教学案例征集',3,'https://www.educoder.net/competitions/ccf-se-2018',0,'2018-08-24 14:23:04','2018-12-14 14:18:50'),
(4,'Java路径',4,'https://www.educoder.net/paths/54',0,'2018-08-24 14:23:23','2019-02-03 19:44:42'),
(5,'Python路径',5,'https://www.educoder.net/paths/11',1,'2018-08-24 14:23:39','2018-08-24 14:24:22'),
(6,'云计算大数据',6,'https://www.educoder.net/paths/29',1,'2018-08-24 14:24:08','2018-08-24 14:24:39'),
(7,'C语言精品课程',3,'https://www.educoder.net/paths/196 ',0,'2019-02-02 19:21:48','2019-06-29 20:14:03'),
(8,'北京大学aixcoder',3,'http://www.aixcoder.com/help/educoder',1,'2019-04-30 14:50:06','2019-06-29 20:13:40'),
(9,'2019绿盟杯竞赛',1,'https://forge.educoder.net/competitions',1,'2019-06-29 10:06:06','2019-07-22 15:02:20');
DROP TABLE IF EXISTS `mirror_repositories`;
CREATE TABLE `mirror_repositories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mirrorID` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`main_type` varchar(255) DEFAULT NULL,
`description` text,
`status` int(11) DEFAULT '0',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`type_name` text,
`script_template` longtext,
`resource_limit` int(11) DEFAULT '10000',
`memory_limit` int(11) DEFAULT '1024',
`cpu_limit` tinyint(4) DEFAULT '1',
`time_limit` int(11) DEFAULT '120',
`should_compile` tinyint(1) DEFAULT NULL,
`repertoire_id` int(11) DEFAULT NULL,
`sub_repertoire_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=130 DEFAULT CHARSET=utf8;
insert into `mirror_repositories`(`id`,`mirrorID`,`name`,`main_type`,`description`,`status`,`created_at`,`updated_at`,`type_name`,`script_template`,`resource_limit`,`memory_limit`,`cpu_limit`,`time_limit`,`should_compile`,`repertoire_id`,`sub_repertoire_id`) values
(2,'5d789e5d495f','python3-ssh:v1.0','1','python3.6.2ssh',1,'2018-01-29 11:31:25','2019-08-24 09:45:27','Python3.6','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="python3.6 "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,2048,2,85,0,2,4),
(3,'42bd3e1427cc','cisco-ssh:v1.0','1','dynagen0.11.0dynamips0.2.8ssh',1,'2018-01-29 11:31:25','2019-08-20 15:45:53','Dynamips','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
#echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="bash "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,6,17),
(4,'b21be9214e36','python2-ssh:v1.0','1','python2.7.9ssh',1,'2018-01-29 11:31:25','2019-08-20 15:47:45','Python2.7','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("" "" "")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="python2.7 "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,2,4),
(5,'eb55c2848120','openjdk-ssh:v1.0','1','java1.8.0zookeeper3.4.12',1,'2018-01-29 11:31:25','2019-08-24 09:44:02','Java','#!/bin/bash
#工作空间
cd WORKSPACE
#用户打开的文件名,之所以传过来这个,是因为可以从这个里面提取出来执行文件名
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
#执行文件名
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#限制每个shell连接所能写文件的最大容量100M
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
#编译命令,有的语言是没有编译过程,这个时候默认编译成功
compileCommand="javac -encoding UTF-8 -Djava.ext.dirs=./lib/ -sourcepath src/ -d target/"
#取当前关卡的编译文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
#当前关卡,作为参数传进来
challengeStage=$1
#删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./target/step$challengeStage/*.class &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
#执行命令
executeCommand="java -Dfile.encoding=UTF-8 -Djava.ext.dirs=./lib/ -cp target/"
#执行文件名
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,50,1,2,4),
(6,'3a0adda6b05f','hive-ssh:v1.0','1','hive-2.3.2ssh',1,'2018-01-29 11:31:25','2019-08-24 09:45:01','Hive',null,100000,2500,2,120,0,5,14),
(7,'c3cac044d76a','hadoop-ssh:v1.0','1','jdk8ant1.10.1hadoop2.7.4ssh 伪分布式',1,'2018-01-29 11:31:25','2019-08-20 15:46:13','Hadoop','#!/bin/bash
#工作空间
cd WORKSPACE
#用户打开的文件名,之所以传过来这个,是因为可以从这个里面提取出来执行文件名
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
#执行文件名
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#限制每个shell连接所能写文件的最大容量100M
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
cd step$1
#编译命令,有的语言是没有编译过程,这个时候默认编译成功
compileCommand="/apache-ant-1.10.1/bin/ant -q -S"
#取当前关卡的编译文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
#当前关卡,作为参数传进来
challengeStage=$1
############################################
compileResult=$($compileCommand 2>&1)
echo $compileResult |grep \'BUILD FAILED\' >/dev/null
if [[ $? == 0 ]]; then
compileResult=$(echo -n $compileResult | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
#执行命令
executeCommand="sh $1.sh"
#执行文件名
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$(cat /tmp/output/part-r-00000 2>/dev/null | base64)\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,2048,1,120,1,5,14),
(8,'a48703cc8a4b','sdl2-vnc:v1.0','1','sdl2vncssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:51','SDL',null,100000,1024,1,120,1,2,null),
(9,'6293d9c4ae5b','php-ssh:v1.0','1','php7.1.10ssh',1,'2018-01-29 11:31:25','2019-08-20 15:47:31','PHP','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("src/step1/SafeDataFillingTest.php" "src/step2/RequiredFieldsTest.php" "src/step3/ValidationOfLegitimacyTest.php" "src/step4/FormDemoTest.php")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
#启动php自建web服务器端口为80
runserver(){
count=`ps -ef | grep php | grep -v grep | wc -l`
if [ 0 -eq $count ]; then
nohup php -S 0.0.0.0:8080 &> /dev/null &
fi
}
runserver
execute(){
executeCommand="php"
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,2,4),
(10,'2f0657d8af26','octave-novnc:v1.0','1','octave4.2.1novnc',1,'2018-01-29 11:31:25','2019-08-24 09:44:14','Matlab','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("step1/f_t_1_c.m" "step2/f_t_2.m")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="octave "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 |grep -vE "warning: function|octave: unable|octave: disabling" | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,2048,1,120,0,8,19),
(12,'c64a7e3a4b1c','git-ssh:v1.0','1','git2.1.4ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:03','Git','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="python "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,6,16),
(13,'e19fc2ec6bb8','gcc-ssh:v1.0','1','gcc7.2.0boost1.66.0opencv3.4.1ssh',1,'2018-01-29 11:31:25','2019-06-25 14:19:52','C/C++','#!/bin/bash
cd WORKSPACE
challengeProgramNames=("src/step1/test.cpp")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="g++ "
challengeProgramName=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
#compile all .c file in the source folder: a/b/c.cpp --> a/b/*.cpp
challengeProgramName=${challengeProgramName%/*.cpp}"/*.cpp"
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="./executeFile.out"
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,40,1,2,4),
(14,'f953dd677e85','ruby-ssh:v1.0','1','ruby2.3.1rails5.2.0ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:45','Ruby','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="ruby "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,2,null),
(15,'e56c4315f99c','ubuntu16-ssh:v1.0','1','ubuntu16.04ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:56','Shell','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("" "" "" "" "" "")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="bash "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,6,16),
(16,'316a8a646cdb','node-ssh:v1.0','1','node9.3.0python2python3htmlhint0.9.13csslint1.0.4ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:36','JavaScript','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("" "" "VariableTest.py")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="node "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,1,1),
(17,'6e04f44485a9','perl6-ssh:v1.0','1','perl6ssh',1,'2018-01-29 11:31:25','2019-08-20 15:47:27','Perl6','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("src/step1/first.pl" "")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="perl6 "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,2,null),
(18,'4e82c3efd0fb','kotlin-ssh:v1.0','1','kotlin1.2.20ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:47','Kotlin','#!/bin/bash
#工作空间
cd WORKSPACE
#用户打开的文件名,之所以传过来这个,是因为可以从这个里面提取出来执行文件名
challengeProgramNames=("src/step1/first.kt" "")
#执行文件名
sourceClassNames=("step1.first" "")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#限制每个shell连接所能写文件的最大容量100M
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="kotlinc -include-runtime -d mainfun.jar"
#取当前关卡的编译文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
#当前关卡,作为参数传进来
challengeStage=$1
#删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./target/step$challengeStage/*.class &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
#执行命令
executeCommand="java -jar mainfun.jar"
#执行文件名
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,1,2,null),
(19,'2de19c574588','elixir-ssh:v1.0','1','elixir1.5.3ssh
',1,'2018-01-29 11:31:25','2019-08-20 15:45:56','Elixir',null,100000,1024,1,120,0,2,null),
(20,'a0067972d5d8','android:v1.0','1','jdk7jdk8android-sdk',1,'2018-01-29 11:31:25','2019-08-20 15:43:33','Android','#!/bin/bash
#工作空间
cd WORKSPACE
#用户打开的文件名,之所以传过来这个,是因为可以从这个里面提取出来执行文件名
challengeProgramNames=("step1/makefile.py" "" "")
#执行文件名
sourceClassNames=("makefile" "" "")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
#限制每个shell连接所能写文件的最大容量100M
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
#执行命令
executeCommand="python makefile.py"
#执行文件名
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
cd step$1
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo "$result"
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,3,5),
(21,'21bf72b5e23e','ubuntu16-xfce-vnc:v1.0','0','VNC图形化镜像',1,'2018-01-29 11:31:25','2019-08-20 15:45:35','VNC',null,100000,1024,1,120,0,6,17),
(22,'30f82079d643','jfinal-mysql55:v1.0','1','tomcat8.5.20mysql5.5jdk1.8ant1.10.1maven3.5.4',1,'2018-01-29 11:31:25','2019-08-28 16:05:17','JavaWeb','#!/bin/bash
cd WORKSPACEjfinalshop
sourceClassNames=("com.jfinalshop.test.TestRunner1" "com.jfinalshop.test.TestRunner2" "com.jfinalshop.test.TestRunner3" "com.jfinalshop.test.TestRunner4" "com.jfinalshop.test.TestRunner5" "com.jfinalshop.test.TestRunner6" "com.jfinalshop.test.TestRunner7")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
restartTomcat(){
bash /home/apache-tomcat-8.5.20/bin/shutdown.sh &> /dev/null
bash /home/apache-tomcat-8.5.20/bin/startup.sh &> /dev/null
while :;
do
sleep 1
cat /home/apache-tomcat-8.5.20/logs/catalina.out| tail -20 | grep \'startup in\' &> /dev/null
if [ $? -eq 0 ]
then
break
fi
done
}
compile(){
compileCommand="ant -q -S"
compileResult=$($compileCommand 2>&1)
failedInfo="BUILD FAILED"
if [[ $compileResult == *$failedInfo* ]]; then
compileResult=$(echo -n $compileResult | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
restartTomcat
fi
}
compile $1
execute(){
executeCommand="java -Dfile.encoding=UTF-8 -Djava.ext.dirs=../../WebRoot/WEB-INF/lib "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,180,0,1,2),
(24,'833b45fe4ce5','go-ssh:v1.0','1','go1.9.2ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:07','Go','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("step1/devide.go" "step2/panic-recover.go" "step3/defertest.go")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="go run "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,2,null),
(27,'7a7980335112','mysql55-ssh:v1.0','0','mysql5.5ssh',1,'2018-01-29 11:31:25','2019-08-20 15:45:51','Mysql',null,100000,1024,1,120,0,4,9),
(29,'d3d83a78ed87','spark-ssh:v1.0','1','jdk8maven3.5.0ssh;',1,'2018-01-29 11:31:25','2019-08-24 09:45:33','Spark',null,100000,2048,1,180,0,5,14),
(30,'f0d5bfc8134e','machine-learning:v1.0','1','python2.7.9python3.6.2jdk8ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:52','MachineLearning','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
execute(){
executeCommand="python "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,180,0,5,12),
(32,'c3f1760586db','iverilog-ssh:v1.0','1','verilog0.10.0ssh',1,'2018-01-29 11:31:25','2019-08-20 15:46:05','Verilog','#!/bin/bash
cd WORKSPACE
challengeProgramNames=("" "")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="iverilog "
challengeProgramName=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="vvp "
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand executeFile.out 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,1,8,19),
(34,'14a2cc7affa2','dind-ssh:v1.0','1','docker17.06.0-cessh',1,'2018-01-29 11:31:25','2019-08-20 15:45:49','Docker','#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=("")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="bash "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
',100000,1024,1,120,0,5,13),
(35,null,null,'0','',1,'2018-01-29 15:15:33','2018-01-29 15:16:03','Html',null,100000,1024,1,120,0,1,1),
(36,null,null,'0','',1,'2018-01-29 15:15:45','2018-01-29 15:15:45','Web',null,100000,1024,1,120,0,1,2),
(39,'405aebc1e662','mono-ssh:v1.0','1','mono5.4.1.7ssh',1,'2018-01-29 16:11:33','2019-08-20 15:44:57','C#',null,100000,1024,1,120,1,2,null),
(64,'d9c6e8954dad','sqlite-ssh:v1.0','1','sqlite3.11.0ssh',1,'2018-03-06 14:03:48','2019-08-20 15:47:08','SQLite3',null,100000,1024,1,120,null,null,null),
(66,'fbaeac72b706','oracle-ssh:v1.0','1','oracle11.2.0.2.0ssh',1,'2018-03-29 15:18:41','2019-08-20 15:47:14','Oracle',null,100000,800,1,240,null,null,null),
(94,'1ed037bbd23f','ghdl-ssh:v1.0','1','ghdl-0.36-devgnat-5.4.0ssh',1,'2018-04-04 17:21:04','2019-08-20 15:45:45','Vhdl',null,100000,1024,1,120,null,null,null),
(95,'46198ab247fb','r-ssh:v1.0','1','R-3.4.4ssh',1,'2018-04-08 10:30:37','2019-08-20 15:46:41','R',null,100000,1024,1,120,null,null,null),
(96,'ea8282136791','swift-ssh:v1.0','1','swift-4.1ssh',1,'2018-04-09 15:13:06','2019-08-20 15:46:15','Swift',null,100000,1024,1,120,null,null,null),
(97,'5d4e4884482c','sqlserver-ssh:v1.0','1','sqlserver2017ssh',1,'2018-04-26 11:55:21','2019-08-20 15:47:15','SQLServer',null,100000,2000,1,120,null,null,null),
(98,'714ba67fe884','mysqlserver55-ssh:v1.0','1','mysql5.5ssh',1,'2018-05-10 09:40:08','2019-08-24 09:45:13','MySQL',null,100000,1024,1,120,null,null,null),
(102,'cf662ab7da9c','ubuntu16-install-ssh:v1.0','1','添加了hadoop3.1.0和jdk1.8的源码包;',1,'2018-06-15 16:49:29','2019-08-20 15:46:09','Ubuntu16-env',null,1000000,2560,1,120,null,null,null),
(104,'24b3af129b64','mongo-ssh:v1.0','1','mogo4.0python3ssh',1,'2018-08-02 15:31:23','2019-08-20 15:47:07','Mongo',null,100000,1024,1,120,null,null,null),
(105,'3614e492d7e9','mongodb-ssh:v1.0','0','mogo4.0python3ssh',1,'2018-08-20 15:39:41','2019-08-20 15:45:56','Mogodb',null,100000,1024,1,120,null,null,null),
(106,'01ed95c29336','python3-vnc:v1.0','1','turtle库python3.5vnc',1,'2018-09-06 11:32:52','2019-08-20 15:46:29','Python3-vnc',null,100000,1024,1,120,null,null,null),
(107,'84499af0600f','python3-competition:v1.0','1','没有安装sklearn包',1,'2018-10-29 10:23:30','2019-06-25 14:17:29','Python3-competition',null,100000,1024,1,120,null,null,null),
(108,'b64b94a5ed4d','hbase-ssh:v1.0','1','Hadoop2.7 JDK8.0 HBase2.1.1 伪分布式',1,'2018-11-14 13:16:45','2019-08-20 15:46:17','Hbase',null,100000,3096,2,200,null,null,null),
(109,'f890a121e481','postgresql-ssh:v1.0','1','postgresql9.5.14ssh',1,'2018-11-15 12:15:17','2019-08-20 15:47:36','PostgreSql',null,100000,1024,1,120,null,null,null),
(110,'bd62c3d558cd','hbase2-ssh:v1.0','1','为分部署定制的镜像。',1,'2018-11-18 15:27:27','2019-08-20 15:46:26','Hbase2',null,100000,4048,1,120,null,null,null),
(111,'fa6acf79f4c2','hbase-simple:v1.0','1','单节点',1,'2018-11-30 15:10:54','2019-08-24 09:45:19','Hbase-simple',null,100000,3072,2,80,null,null,null),
(112,'b1b1eb1ad716','sqoop-ssh:v1.0','1','Hbase基础上安装了 sqoop',1,'2018-12-18 09:21:54','2019-08-20 15:46:24','Sqoop',null,100000,2048,1,120,null,null,null),
(113,null,null,'0','',1,'2018-12-20 10:20:33','2018-12-20 10:20:33','Css',null,100000,1024,1,120,null,null,null),
(114,'433f4526ec22','nasm-ssh:v1.0','1','汇编语言',1,'2019-02-18 17:13:34','2019-08-20 15:47:10','Nasm',null,100000,1024,1,120,null,null,null),
(115,'6f3c7e80aeea','ubuntu-nvidia:v1.0','1','GPU',1,'2019-03-07 14:32:45','2019-08-24 09:47:22','Python-Gpu',null,100000,2048,1,120,null,null,null),
(116,'90366fe59219','python3-tentensorflow1.5-ssh:v1.0','1','',1,'2019-03-08 10:48:22','2019-08-20 15:47:53','Python3-tentensorflow1.5',null,100000,2048,1,120,null,null,null),
(118,'53ffa15bc4ec','kafka-ssh:v1.0','1','kafka_2.11-1.1.0afka_2.11-1.1.0sshmvn',1,'2019-03-20 17:33:46','2019-08-24 09:44:08','Kafka',null,100000,2500,1,120,null,null,null),
(119,'b3f6ce4aafbb','vscode-novnc:v1.0','1','VSCode、novnc、netsurf、ssh、pip3、flask、sogou;',1,'2019-05-29 17:42:02','2019-08-24 09:45:42','VSCode',null,100000,2048,1,120,null,null,null),
(120,'45221690780b','ubuntu-nvidia-c:v1.0','1','cuda、mpi',1,'2019-06-05 17:46:20','2019-08-24 09:47:31','GPU-C/C++',null,100000,1024,1,120,null,null,null),
(123,'c4f0b2ef2ed2','flink-mysql55:v1.0','1','flink1.8、mvn、jdk8;',1,'2019-06-17 16:10:27','2019-08-24 09:43:36','Flink',null,100000,3072,1,120,null,null,null),
(124,'bdfb097d9a30','matlab-novnc:v1.0','1','matlab2017图形化',1,'2019-06-25 13:29:14','2019-08-24 09:45:08','Matlab/vnc',null,100000,2048,2,120,null,null,null),
(126,'12450a0d48ea','sqlserver-ssh2:v1.0',null,null,0,'2019-06-26 10:23:18','2019-06-26 10:23:18',null,null,100000,1024,1,120,null,null,null),
(127,'16e3a8b20df2','cisco-novnc:v1.0','1','cisco、vscode、firefox、wireshark',1,'2019-07-17 17:03:53','2019-08-24 09:43:24','Cisco',null,100000,1024,1,120,null,null,null),
(129,'77520d805023','hbase-finish-ssh:v1.0','1','hbase 2.0.0',1,'2019-08-13 16:30:16','2019-08-29 10:52:37','Hbase-finish',null,100000,2048,1,120,null,null,null);
DROP TABLE IF EXISTS `mirror_scripts`;
CREATE TABLE `mirror_scripts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mirror_repository_id` int(11) DEFAULT NULL,
`script` longtext,
`script_type` varchar(255) DEFAULT NULL,
`description` text,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8;
insert into `mirror_scripts`(`id`,`mirror_repository_id`,`script`,`script_type`,`description`,`created_at`,`updated_at`) values
(1,13,'#!/bin/bash
cd WORKSPACE
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="gcc -lm -lc -lz "
challengeProgramName=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
#compile all .c file in the source folder: a/b/c.c --> a/b/*.c
challengeProgramName=${challengeProgramName%/*.c}"/*.c"
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="./executeFile.out"
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
','C','C','2018-01-29 14:43:15','2019-07-19 13:53:37'),
(2,13,'#!/bin/bash
cd WORKSPACE
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="g++ "
challengeProgramName=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
#compile all .c file in the source folder: a/b/c.cpp --> a/b/*.cpp
challengeProgramName=${challengeProgramName%/*.cpp}"/*.cpp"
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="./executeFile.out"
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
','C++','C++','2018-01-29 14:43:33','2018-01-29 14:43:33'),
(3,20,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Android','Android','2018-01-29 14:45:55','2019-07-19 13:52:03'),
(4,34,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Docker','Docker','2018-01-29 14:57:28','2019-07-19 11:23:54'),
(5,3,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Dynamips','Dynamips','2018-01-29 14:58:29','2019-07-19 11:25:27'),
(6,19,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="elixir"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Elixir','Elixir','2018-01-29 14:59:17','2019-07-19 11:27:24'),
(7,12,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Git','Git','2018-01-29 14:59:50','2019-07-19 11:31:34'),
(8,24,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="go run"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Go','Go','2018-01-29 15:00:35','2019-07-19 11:33:07'),
(9,7,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 编译函数
compile(){
cd step$1
# 编译命令
compileCommand="/apache-ant-1.10.1/bin/ant -q -S"
# 取当前关卡的编译文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
############################################
compileResult=$($compileCommand 2>&1)
echo $compileResult |grep \'BUILD FAILED\' >/dev/null
if [[ $? == 0 ]]; then
compileResult=$(echo -n $compileResult | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
# 执行命令
executeCommand="sh $1.sh"
# 执行文件名
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$(cat /tmp/output/part-r-00000 2>/dev/null | base64)\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult
','Hadoop','Hadoop','2018-01-29 15:01:06','2019-07-19 11:38:37'),
(10,6,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','hive-shell','','2018-01-29 15:01:39','2019-07-19 14:14:41'),
(11,5,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件(可能是编译所得的可执行文件,请按实际情况填写)
sourceClassNames=(SOURCECLASSNAMES)
# 编译命令
compileCommand="javac -encoding UTF-8 -Djava.ext.dirs=./lib/ -sourcepath src/ -d target/"
# 执行命令
executeCommand="java -Dfile.encoding=UTF-8 -Djava.ext.dirs=./lib/ -cp target/"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 限制每个shell连接所能写文件的最大容量
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
# 编译函数
compile(){
# 创建target目录
mkdir target &> /dev/null
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -rf ./target/** &> /dev/null
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接执行结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult
','Java','Java','2018-01-29 15:02:23','2019-07-19 14:16:22'),
(12,16,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="node"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','JavaScript','JavaScript','2018-01-29 15:03:04','2019-07-19 14:18:41'),
(13,22,'#!/bin/bash
#tomcat路径:/home/apache-tomcat-8.5.20/
cd WORKSPACEjfinalshop
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
restartTomcat(){
bash /home/apache-tomcat-8.5.20/bin/shutdown.sh &> /dev/null
bash /home/apache-tomcat-8.5.20/bin/startup.sh &> /dev/null
while :;
do
sleep 1
cat /home/apache-tomcat-8.5.20/logs/catalina.out| tail -20 | grep \'startup in\' &> /dev/null
if [ $? -eq 0 ]
then
break
fi
done
}
compile(){
compileCommand="ant -q -S"
compileResult=$($compileCommand 2>&1)
failedInfo="BUILD FAILED"
if [[ $compileResult == *$failedInfo* ]]; then
compileResult=$(echo -n $compileResult | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
restartTomcat
fi
}
compile $1
execute(){
executeCommand="java -Dfile.encoding=UTF-8 -Djava.ext.dirs=../../WebRoot/WEB-INF/lib "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
# 切换到编译文件的目录
cd build/classes
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
','JFinal','JFinal','2018-01-29 15:03:43','2019-07-19 14:22:22'),
(14,18,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 编译命令
compileCommand="kotlinc -include-runtime -d mainfun.jar"
# 执行命令
executeCommand="java -jar mainfun.jar"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 编译函数
compile(){
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -rf *.jar &> /dev/null
rm -rf ./target/** &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult
','Kotlin','Kotlin','2018-01-29 15:04:13','2019-07-19 14:26:51'),
(15,30,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','MachineLearning','MachineLearning','2018-01-29 15:04:49','2019-07-19 14:28:50'),
(16,10,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="octave"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 |grep -vE "warning: function|octave: unable|octave: disabling" | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Matlab','Matlab','2018-01-29 15:05:27','2019-07-19 14:30:10'),
(17,17,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="perl6"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Perl6','Perl6','2018-01-29 15:06:34','2019-07-19 15:00:31'),
(18,9,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="php"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','PHP','PHP','2018-01-29 15:07:02','2019-07-19 15:03:08'),
(19,4,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Python2.7','Python2.7','2018-01-29 15:09:20','2019-07-19 15:12:14'),
(20,2,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Python3.6','Python3.6','2018-01-29 15:10:18','2019-07-19 15:22:37'),
(21,2,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环检测数据库是否已启动
while :;
do
mysql -h127.0.0.1 -uroot -p123123 -e "show databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Python3.6/Mysql','mysql','2018-01-29 15:10:30','2018-01-31 11:17:22'),
(22,14,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="ruby"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Ruby','Ruby','2018-01-29 15:11:04','2019-07-19 15:26:36'),
(23,8,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 编译命令
compileCommand="gcc $challengeProgramName -lSDL2 -lSDL2_image -lSDL2_mixer"
# 执行命令
executeCommand="./a.out"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 编译函数
compile(){
# 当前关卡号
challengeStage=$1
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./target/step$challengeStage/*.class &> /dev/null
#compile 编译文件并将编译结果输出至compile_result_$challengeStage.out
$compileCommand > compile_result_$challengeStage.out 2>&1
#检测编译输出文件是否为空,编译成功的时候没有输出,有输出就说明编译失败。
#拿到编译结果并用base64编码
compileResult=\'\'
if test -s compile_result_$challengeStage.out; then
compileResult=$(cat compile_result_$challengeStage.out | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','SDL','SDL','2018-01-29 15:11:50','2019-07-19 15:28:33'),
(24,15,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Shell','','2018-01-29 15:12:29','2019-07-19 15:34:04'),
(25,29,'########
#有些命令会有不必要的输出要过滤掉grep -v或者直接去掉所有输出2>&1 >/dev/null
########
#进入版本库目录WORKSPACE平台会替换为版本库的绝对路径
cd WORKSPACE
#将spark实训程序所需输入文件放入/tmp/路径,程序再从/tmp/1.txt读取输入因为代码拿不到版本库输入文件的绝对路径
cp ./1.txt /tmp/ 2>&1 >/dev/null
#mvn编译时的路径
CompilePath=("第一关编译路径" "第二关编译路径" "第三关编译路径" "...")
#mvn编译命令
compileCommand="mvn package "
#spark执行的jar包的绝对路径WORKSPACE+当前路径=绝对路径)
ExecutePath=("WORKSPACE/step1/target/*.jar" "WORKSPACE/step2/target/*.jar" "WORKSPACE/step3/target/*.jar")
#执行命令
executeCommand="spark-submit --class $ClassName_Now $ExecutePath_Now"
#spark执行时的class名称
ClassName=("step1" "step2" "step3")
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
#编译函数
compile(){
#获取当前关卡的编译路径
CompilePath_Now=${CompilePath[$1 - 1]}
#进入编译目录
cd $CompilePath_Now
#清除历史jar包
rm -f ./target/*.jar 2>&1 >/dev/null
#获取编译结果
compileResult=$($compileCommand 2>&1 | base64)
if [ -f ./target/*.jar ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
#"$1"第几关1/2/3..)为平台传入的编译函数执行参数
compile $1
execute(){
#获取当前关卡执行文件路径
ExecutePath_Now=${ExecutePath[$1 - 1]}
#获取当前关卡执行类名
ClassName_Now=${ClassName[$1 - 1]}
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
#使用sed命令过滤掉没用的输出
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand 2>&1 |grep -vE "spark-env|SPARK_LOCAL_IP|Printing new" |sed \'s/.*(/(/\' | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
','Spark','Spark','2018-01-29 15:13:08','2019-07-19 15:36:28'),
(26,32,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 编译命令
compileCommand="iverilog"
# 执行命令
executeCommand="vvp"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 编译函数
compile(){
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./executeFile.out &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand executeFile.out 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult
','Verilog','Verilog','2018-01-29 15:13:46','2019-07-19 15:49:43'),
(27,39,'#!/bin/bash
#工作空间
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件(可能是编译所得的可执行文件,请按实际情况填写)
sourceClassNames=(SOURCECLASSNAMES)
# 编译命令
compileCommand="mcs -warn:0"
# 执行命令
executeCommand="mono"
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#限制每个shell连接所能写文件的最大容量100M
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
#取当前关卡的编译文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
#当前关卡,作为参数传进来
challengeStage=$1
#删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./target/step$challengeStage/*.class &> /dev/null
#compile 编译文件并将编译结果输出至compile_result_$challengeStage.out
$compileCommand $challengeProgramName > compile_result_$challengeStage.out 2>&1
#检测编译输出文件是否为空,编译成功的时候没有输出,有输出就说明编译失败。
#拿到编译结果并用base64编码
compileResult=\'\'
if test -s compile_result_$challengeStage.out; then
compileResult=$(cat compile_result_$challengeStage.out | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult','C#','C#标准脚本','2018-01-29 16:17:52','2019-07-19 13:53:10'),
(29,9,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="php"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环检测数据库是否已启动
while :;
do
mysql -h127.0.0.1 -uroot -p123123 -e "show databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','PHP/MYSQL','','2018-02-02 16:43:14','2018-02-02 16:43:14'),
(30,5,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件(可能是编译所得的可执行文件,请按实际情况填写)
sourceClassNames=(SOURCECLASSNAMES)
# 编译命令
compileCommand="javac -encoding UTF-8 -Djava.ext.dirs=./lib/ -sourcepath src/ -d target/"
# 执行命令
executeCommand="java -Dfile.encoding=UTF-8 -Djava.ext.dirs=./lib/ -cp target/"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 限制每个shell连接所能写文件的最大容量
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
# 编译函数
compile(){
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./target/step$challengeStage/*.class &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环检测数据库是否已启动
while :;
do
mysql -h127.0.0.1 -uroot -p123123 -e "show databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接执行结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult
','Java/Mysql','mysql','2018-02-02 16:44:30','2018-02-02 16:44:30'),
(31,4,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环检测数据库是否已启动
while :;
do
mysql -h127.0.0.1 -uroot -p123123 -e "show databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Python2.7/Mysql','mysql','2018-02-02 16:45:53','2018-02-02 16:45:53'),
(32,9,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="php"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 启动php自建web服务器端口为80
runserver(){
# 判断php是否已启动未启动则启动phpweb
ps -ef | grep php | grep -v grep
if [ $? -eq 0 ]; then
nohup php -S 0.0.0.0:8080 &> /dev/null &
fi
}
runserver
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','PHP-Web','PHP-Web','2018-02-02 17:06:57','2018-02-02 17:11:39'),
(33,64,'#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="bash "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult','SQLite3','SQLite','2018-03-06 14:07:08','2019-07-19 15:38:42'),
(34,66,'#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
sourceClassName=${sourceClassNames[$1 - 1]}
executeCommand="sqlplus system/oracle @./$sourceClassName "
challengeStage=$1
while :
do
stat=`service oracle-xe status |grep READY|wc -l`
if [ $stat == 2 ];then
break
else
sleep 1
fi
done
#get the loop times(looptimes = the num of testdataset)
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand |sed -n \'9,10000p\'|grep -v \'Disconnected from\' 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult','Oracle','Oracle','2018-03-29 15:21:34','2019-07-19 14:58:49'),
(35,94,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件(可能是编译所得的可执行文件,请按实际情况填写)
sourceClassNames=(SOURCECLASSNAMES)
# ins:各测试用例输入所组成的数组 $1:当前关卡号 $2:测试用例原始输入
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 限制每个shell连接所能写文件的最大容量
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
# 编译函数
compile(){
# 编译命令
compileCommand="ghdl -a"
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./target/step$challengeStage/*.class &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 执行命令
executeCommand="ghdl -r entity_name"
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
# 执行
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand 2>&1 | base64)
# 拼接执行结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult
','Vhdl','Vhdl','2018-04-04 17:22:33','2019-07-19 15:51:49'),
(36,95,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="Rscript"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','R','R','2018-04-08 10:32:20','2019-07-19 15:24:13'),
(37,96,'#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="swift"
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult','swift','swift','2018-04-09 15:13:58','2019-07-19 15:43:46'),
(38,13,'#!/bin/bash
cd WORKSPACE
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="g++ `pkg-config --cflags --libs opencv` "
challengeProgramName=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
#compile all .c file in the source folder: a/b/c.cpp --> a/b/*.cpp
challengeProgramName=${challengeProgramName%/*.cpp}"/*.cpp"
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="./executeFile.out"
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
','Opencv','g++
','2018-04-25 10:31:50','2018-04-25 10:32:14'),
(39,97,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="sqlcmd -S localhost -U sa "
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环检测数据库是否已启动
while :;
do
sqlcmd -S localhost -U sa -P \'<123123Aa!@>\' -Q "SELECT Name from sys.Databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand -P \'<123123Aa!@>\' -i $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Sqlserver','Sqlserver','2018-04-26 14:05:13','2019-07-19 15:40:11'),
(41,98,'#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
executeCommand="mysql -h127.0.0.1 -uroot -p123123 "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
# 循环检测数据库是否已启动
while :;
do
mysql -h127.0.0.1 -uroot -p123123 -e "show databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
#get the loop times(looptimes = the num of testdataset)
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand < $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult','Mysql55','Mysqlsql','2018-05-10 15:11:34','2019-07-19 14:48:08'),
(42,98,'#!/bin/bash
cd WORKSPACE
#前台传来的可执行文件,即测试文件
sourceClassNames=(SOURCECLASSNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
#不需要编译,设定编译结果为成功编译
compileResult=$(echo -n "compile successfully" | base64)
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
execute(){
# 循环检测数据库是否已启动
while :;
do
mysql -h127.0.0.1 -uroot -p123123 -e "show databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
executeCommand="bash "
sourceClassName=${sourceClassNames[$1 - 1]}
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult','Mysql55-shell','Mysql55shell','2018-05-10 15:12:00','2018-07-23 14:21:30'),
(43,97,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件(可能是编译所得的可执行文件,请按实际情况填写)
sourceClassNames=(SOURCECLASSNAMES)
# 编译命令
compileCommand="javac -encoding UTF-8 -Djava.ext.dirs=./lib/ -sourcepath src/ -d target/"
# 执行命令
executeCommand="java -Dfile.encoding=UTF-8 -Djava.ext.dirs=./lib/ -cp target/"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 限制每个shell连接所能写文件的最大容量
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
# 编译函数
compile(){
# 创建target目录
mkdir target &> /dev/null
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -f ./target/step$challengeStage/*.class &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 循环检测数据库是否已启动
while :;
do
sqlcmd -S localhost -U sa -P \'<123123Aa!@>\' -Q "SELECT Name from sys.Databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接执行结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult
','Sqlserver/Java','javasqlserver','2018-05-25 15:30:11','2018-05-25 15:30:11'),
(44,97,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash "
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环检测数据库是否已启动
while :;
do
sqlcmd -S localhost -U sa -P \'<123123Aa!@>\' -Q "SELECT Name from sys.Databases" 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName | tr -s \' \' |tr \' \' \'\\t\' 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Sqlserver/Shell','','2018-06-12 17:10:44','2018-06-12 17:25:07'),
(45,102,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Shell/Hadoop','Shell','2018-06-15 16:52:37','2019-07-19 15:47:05'),
(46,7,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Hadoop/Shell','使shell','2018-07-10 09:07:17','2018-07-10 09:07:17'),
(47,2,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Python3.6/Shell','Shell','2018-07-16 11:28:41','2018-07-16 11:28:41'),
(48,7,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 编译函数
compile(){
cd step$1
# 编译命令
compileCommand="/apache-ant-1.10.1/bin/ant -q -S"
# 取当前关卡的编译文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
############################################
compileResult=$($compileCommand 2>&1)
echo $compileResult |grep \'BUILD FAILED\' >/dev/null
if [[ $? == 0 ]]; then
compileResult=$(echo -n $compileResult | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
# 执行命令
executeCommand="sh $1.sh"
# 执行文件名
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult
','Hadoop/v2.0','','2018-08-02 09:36:26','2018-08-02 09:36:26'),
(49,104,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Mongo/Python','python3','2018-08-02 15:33:19','2019-07-19 14:45:30'),
(50,104,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Mongo/Shell','shell','2018-08-02 15:33:53','2018-08-02 15:33:53'),
(54,106,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Python3-vnc/Shell','shell','2018-09-10 09:11:01','2019-07-19 15:20:06'),
(55,22,'#!/bin/bash
cd WORKSPACE/verifycode
sourceClassNames=("com.servlet.CodeTest.txt" "com.servlet.LoginTest.txt" "com.servlet.CaptchaTest.txt")
OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
startJetty(){
nohup mvn jetty:run-war &> /dev/null &
}
restartJetty(){
rm nohup.out
mvn jetty:stop &> nohup.out
startJetty
while :;
do
sleep 1
netstat -antplu |grep 8080 &> /dev/null
if [ $? -eq 0 ]
then
break
fi
done
}
compile(){
compileCommand="mvn compiler:compile"
compileResult=$($compileCommand 2>&1)
if [[ $(echo $?) -ne 0 ]]; then
compileResult=$(echo -n $compileResult | base64)
else
compileResult=$(echo -n "compile successfully" | base64)
restartJetty
fi
}
compile
execute(){
sourceClassName=${sourceClassNames[$1 - 1]}
executeCommand="echo $(awk -F \',\' \'{print $2 $3}\' target/surefire-reports/"${sourceClassName}" ) "
output=\'\'
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Mvn/Jetty','Mvn/Jetty','2018-09-17 15:40:14','2018-09-17 15:40:14'),
(56,107,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','python','','2018-10-29 10:25:27','2019-07-19 15:15:57'),
(57,108,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Hbase/shell','使shell','2018-11-14 13:18:24','2019-07-19 11:40:27'),
(58,109,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
while :;
do
sudo -u postgres psql -c "\\dt" 2>&1 > /dev/null 2>&1 >/dev/null
if [ $? -eq 0 ];then
break
else
sleep 1
fi
done
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','PostgreSql/Shell','','2018-11-15 12:16:46','2019-07-19 15:06:01'),
(59,110,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Hbase2/shell','','2018-11-18 15:28:30','2019-07-19 14:12:12'),
(60,111,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Hbase-simple/Shell','','2018-11-30 15:11:45','2019-07-19 14:10:00'),
(61,29,'#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件(可能是编译所得的可执行文件,请按实际情况填写)
sourceClassNames=(SOURCECLASSNAMES)
# 编译命令
compileCommand="scalac -encoding UTF-8 -sourcepath src/ -d target/"
# 执行命令
executeCommand="scala -Dfile.encoding=UTF-8 -cp target/"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
# 限制每个shell连接所能写文件的最大容量
echo \'ulimit -f 10000\' >>/root/.bashrc ; source /root/.bashrc
# 编译函数
compile(){
# 创建target目录
mkdir target &> /dev/null
# 当前关卡的编译目标文件
challengeProgramName=${challengeProgramNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 删除上一次编译生成的文件,防止对本次编译造成影响
rm -rf ./target/** &> /dev/null
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接执行结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult
','Scala','','2018-12-09 16:26:59','2018-12-10 16:19:29'),
(62,112,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Sqoop/shell','','2018-12-18 09:22:55','2019-07-19 15:41:44'),
(63,114,'#!/bin/bash
cd WORKSPACE
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
#example编译命令nasm -f elf64 hello.asm
compileCommand="nasm -f elf64 "
challengeProgramName_only=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
rm -f ./executeFile1.out &> /dev/null
#compile all .s file in the source folder: a/b/c.s --> a/b/*.s
challengeProgramName=${challengeProgramName_only%/*.s}"/*.s"
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile1.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
#example编译命令ld -s hello -o hello.o
compileResult=$(ld -s executeFile1.out -o executeFile.out 2>&1 | base64)
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
if [ -z "$compileResult" ]; then
compileResult1=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="./executeFile.out"
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult','Nasm/shell','','2019-02-18 17:14:35','2019-07-19 14:50:52'),
(64,34,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Docker/python','使Python','2019-02-22 14:23:47','2019-02-22 14:23:47'),
(66,5,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Java/Shell','Shell','2019-03-07 16:14:54','2019-03-12 16:36:52'),
(68,116,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Python3-tentensorflow1.5/Shell','','2019-03-08 10:50:49','2019-07-19 15:17:55'),
(69,116,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Python3-tentensorflow1.5','','2019-03-08 10:50:59','2019-03-08 10:50:59'),
(71,22,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','JavaWeb/Shell','java shell','2019-03-12 16:52:10','2019-03-12 16:52:10'),
(73,13,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','C/Shell','shell','2019-03-18 17:43:29','2019-03-18 17:43:29'),
(74,118,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Kafka/Shell','','2019-03-20 17:35:42','2019-07-19 14:24:39'),
(75,10,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Matlab/Shell','','2019-03-25 10:07:54','2019-06-25 14:25:55'),
(77,2,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
#启动php自建web服务器端口为80
runserver(){
pkill -f "manage.py runserver"
lsof -i:8080 &> /dev/null
if [ $? -eq 1 ]; then
nohup python ${sourceClassNames[$1 - 1]} runserver 0.0.0.0:8080 &> /dev/null &
fi
while :;
do
sleep 1
lsof -i:8080 &> /dev/null
if [ $? -eq 0 ]
then
break
fi
done
}
runserver $1
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName test apptest 2>&1)
result=$(echo "${result/in [0-9].[0-9][0-9][0-9]s}" | base64)
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','Python3.6/Django','45appteseapp
Djangotests.pytests.py"in 0.000s"','2019-04-12 17:06:00','2019-06-04 17:49:35'),
(78,29,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','spark-shell','shell','2019-04-22 10:26:39','2019-04-22 10:26:39'),
(79,109,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="python"
# 获取测试用例的输入(请勿改动此行语句)
input=$2; OLD_IFS="$IFS"; IFS=,; ins=($input); IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','PostgreSql/Python','','2019-05-07 15:28:55','2019-05-07 15:28:55'),
(80,119,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Shell/vscode','','2019-05-29 17:43:47','2019-07-19 15:53:12'),
(81,120,'#!/bin/bash
cd WORKSPACE
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="gcc -lm -lc -lz "
challengeProgramName=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
#compile all .c file in the source folder: a/b/c.c --> a/b/*.c
challengeProgramName=${challengeProgramName%/*.c}"/*.c"
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="./executeFile.out"
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand | base64)
#拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
','GPU/C','','2019-06-05 17:48:14','2019-07-19 11:36:10'),
(82,120,'#!/bin/bash
cd WORKSPACE
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
echo \'ulimit -f 1000000\' >>/root/.bashrc ; source /root/.bashrc
compile(){
compileCommand="g++ "
challengeProgramName=${challengeProgramNames[$1 - 1]}
#remove the executeFile.out file that last time remains
rm -f ./executeFile.out &> /dev/null
#compile all .c file in the source folder: a/b/c.cpp --> a/b/*.cpp
challengeProgramName=${challengeProgramName%/*.cpp}"/*.cpp"
# 获取编译结果(此处编译无输出则说明编译通过,否则输出编译错误信息,请按实训实际情况调整)
compileResult=$($compileCommand $challengeProgramName -o executeFile.out 2>&1 | base64)
if [ -z "$compileResult" ]; then
compileResult=$(echo -n "compile successfully" | base64)
fi
}
compile $1
execute(){
executeCommand="./executeFile.out"
challengeStage=$1
#get the loop times(looptimes = the num of testdataset)
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
#执行,并拼接执行结果
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand | base64)
#拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
#return result in json format
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
#拼装成最终的json格式echo输出得到最后结果
returnResult
','GPU/C++','','2019-06-05 17:48:36','2019-06-05 17:48:36'),
(83,120,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','GPU/C/Shell','','2019-06-05 17:48:57','2019-06-05 17:48:57'),
(84,123,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Shell/Flink','','2019-06-17 16:19:57','2019-07-19 11:29:05'),
(85,124,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Matlab-vnc/shell','','2019-06-25 14:26:19','2019-07-19 14:42:10'),
(86,127,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Shell/cisco','','2019-07-17 17:06:00','2019-07-19 13:54:05'),
(87,115,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Python-Gpu/Shell','','2019-07-19 15:10:36','2019-07-19 15:13:52'),
(88,null,null,null,null,'2019-08-13 16:46:05','2019-08-13 16:46:05'),
(89,129,'#!/bin/bash
cd WORKSPACE
# 待执行的评测文件
sourceClassNames=(SOURCECLASSNAMES)
# 执行命令
executeCommand="bash"
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
compileResult=$(echo -n "compile successfully" | base64)
# 执行函数
execute(){
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
res_usage="{\\"testSetUsages\\":["
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
echo 0 > /sys/fs/cgroup/memory/memory.max_usage_in_bytes
startCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
endCpuUsage=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage)
let testSetCpuUsage=$endCpuUsage-$startCpuUsage
maxMemUsage=$(cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes)
res_usage="$res_usage{\\"testSetTime\\":\\"$testSetCpuUsage\\",\\"testSetMem\\":\\"$maxMemUsage\\"},"
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
res_usage="${res_usage::-1}"
res_usage="$res_usage]}"
res_usage=$(echo -ne "$res_usage"|base64)
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output,\\"resUsage\\":\\"$res_usage\\"}"
echo $result
}
returnResult','Hbase-finish/Shell','','2019-08-13 16:47:52','2019-08-13 16:47:52');
DROP TABLE IF EXISTS `platform_samples`;
CREATE TABLE `platform_samples` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`samples_type` varchar(255) DEFAULT NULL,
`contents` text,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
insert into `platform_samples`(`id`,`samples_type`,`contents`,`created_at`,`updated_at`) values
(1,'taskPass','[TOC]
---
####任务描述
####相关知识
1.2.
#####获取数组的长度
`length`
```java
int[] nums = new int[10];//int10
System.out.println(nums.length);//
```
`10`
#####遍历数组
****
```java
int[] arr = {1,3,5,7,9};
for(int i = 0 ; i<arr.length; i++){
System.out.print(arr[i] + ",");
}
```
`1,3,5,7,9`
#####如何求出最大值
max
####编程要求
####测试说明
`4``91``51``2``32`
`44.0`
`91`
`5``1``151``12``22``100`
`57.2`
`151`
```java
int a = 3;
int b = 2;
System.out.println(a/b);
System.out.println((double)(a/b));
```
`1`
`1.5`
---
','2018-01-05 21:10:42','2018-11-26 09:09:43'),
(2,'script','#!/bin/bash
cd WORKSPACE
# 待编译的评测文件
challengeProgramNames=(CHALLENGEPROGRAMNAMES)
# 待执行的评测文件(可能是编译所得的可执行文件,请按实际情况填写)
sourceClassNames=(SOURCECLASSNAMES)
# 获取测试用例的输入(请勿改动此行语句)
input=$2;OLD_IFS="$IFS"; IFS=,; ins=($input);IFS="$OLD_IFS"
COMPILEFUNCTION
execute(){
# 执行命令
executeCommand="EXECUTECOMMAND"
# 当前关卡的执行目标文件
sourceClassName=${sourceClassNames[$1 - 1]}
# 当前关卡号
challengeStage=$1
# 循环获取各测试用例下的实际输出
output=\'\'
i=0
while [[ i -lt ${#ins[*]} ]]; do
result=$(echo "${ins[$i]}" | base64 -d | $executeCommand $sourceClassName 2>&1 | base64)
# 拼接输出结果
output=$output\\"$result\\",
let i++
done
output="[${output%?}]"
}
execute $1
# 返回评测结果
returnResult(){
result="{\\"compileResult\\":\\"$compileResult\\",\\"out\\":$output}"
echo $result
}
returnResult','2018-01-29 16:21:11','2018-02-01 14:36:37'),
(3,'introduction','[comment]: <> (请在此添加实训简介,简单介绍一下实训的内容.以下是“基于Java语言的链表编程实训基础篇”实训的示例文)
Linked ListArray
Java线
![](/api/attachments/169735)','2018-02-07 17:02:53','2018-02-07 17:02:53'),
(4,'knowledge','[comment]: <> (请在此添加实训历史背景、应用背景拓展学员视野.以下是“基于Java语言的链表编程实训基础篇”实训的示例)
#### 链表的历史
19551956Allen NewellCliff ShawHerbert A. SimonIPLIPLRAND CorporationIPLLogic Theory MachineGeneral Problem Solver
![](/api/attachments/169231)
1975NewellSimonACM Turing Award
#### 链表的适用范围和基本原理
-
-
- 访
#### 链表的分类
-
Singly Linked Listnextnull
![](/api/attachments/169232)
-
Doubly Linked Listprenextheadprenulltailnull
![](/api/attachments/169233)
-
Circular Linked Listprenext
![](/api/attachments/169234)
####链表与数组的对比
:
![](/api/attachments/169235)
使
#### 延伸阅读
* (Mark Allen Weiss), :Java(3), , 201631
* Wikipeida, Linked list https://en.wikipedia.org/wiki/Linked_list
* , , , https://www.zhihu.com/question/19773378
','2018-02-07 17:03:17','2018-02-07 17:03:17'),
(5,'courseGuide','大家好!
线
线
- Python[Python](https://www.educoder.net/paths/13) | [Python](https://www.educoder.net/paths/11)
- Java[Java](https://www.educoder.net/paths/38)
- C/C++[C/C++](https://www.educoder.net/paths/3) | [C](https://www.educoder.net/paths/4)
- Matlab[MATLAB](https://www.educoder.net/shixuns/7bvs54gw/challenges) | [](https://www.educoder.net/shixuns/q4fowkfa/challenges) | [](https://www.educoder.net/shixuns/grunzcs3/challenges)
- HTML/CSS[HTML5+CSS3](https://www.educoder.net/paths/15)
- [Docker](https://www.educoder.net/paths/29)
... ...
','2018-04-20 09:10:16','2018-04-20 09:10:16');
SET FOREIGN_KEY_CHECKS = 1;