-
在我的机器上编译和运行一个随机用户C++程序
加上我自己的代码)
-
我在Amazon AWS Linux微实例上运行docker。我做了以下工作:
定制并构建了一个名为sandbox的Ubuntu映像,其中包含了我需要的所有软件包(g++、valgrind、make等)
在包含我的pre-req文件的另一个目录中,我复制用户文件。然后我从这个目录中构建一个新的docker映像,这个目录使用沙盒基础映像构建。我的卷宗上写着:
FROM sandbox
COPY . /sandbox
RUN make
307 {aws-028}testcpp: docker build --tag=test .
Sending build context to Docker daemon 35.33kB
Step 1/5 : FROM sandbox
---> 42fdf2be6912
Step 2/5 : MAINTAINER AVFILT
---> Running in d5531528333c
Removing intermediate container d5531528333c
---> 561070a04095
Step 3/5 : WORKDIR /sandbox
---> Running in 7d1afb32f3ef
Removing intermediate container 7d1afb32f3ef
---> e416508e5180
Step 4/5 : COPY . /sandbox
---> 8392a378a6a2
Step 5/5 : RUN make
---> Running in bf041f3a5353
g++ -Wall -O0 -std=c++0x *.cpp
valgrind ./a.out # >a.log 2>&1
==22== Memcheck, a memory error detector
==22== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==22== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==22== Command: ./a.out
==22==
Success. All tests passed. Congratulations.
==22==
==22== HEAP SUMMARY:
==22== in use at exit: 72,704 bytes in 1 blocks
==22== total heap usage: 3,881 allocs, 3,880 frees, 524,711 bytes allocated
==22==
==22== LEAK SUMMARY:
==22== definitely lost: 0 bytes in 0 blocks
==22== indirectly lost: 0 bytes in 0 blocks
==22== possibly lost: 0 bytes in 0 blocks
==22== still reachable: 72,704 bytes in 1 blocks
==22== suppressed: 0 bytes in 0 blocks
==22== Rerun with --leak-check=full to see details of leaked memory
==22==
==22== For counts of detected and suppressed errors, rerun with: -v
==22== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Removing intermediate container bf041f3a5353
---> 9cf23028b470
Successfully built 9cf23028b470
Successfully tagged test:latest
我将上述输出捕获到一个本地文件中,然后使用脚本对其进行处理。
如果我反复多次这样做,我能不能假设每次运行都不会留下待清理的悬挂数据(最终耗尽磁盘空间)?
非常感谢你,
&安培;