模拟没有可用磁盘空间的情况最简单的方法? [英] Easiest way to simulate no free disk space situation?

查看:186
本文介绍了模拟没有可用磁盘空间的情况最简单的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试我的web应用程序的一个场景,有没有剩余的磁盘空间,即我不能写任何文件。但我不希望我的填写与垃圾的硬盘只是为了确保真的没有剩余空间。我想要的是模拟这种情况withing特定进程(实际上是一个PHP应用程序)。

I need to test my web app in a scenario where there’s no disk space remaining, i.e. I cannot write any more files. But I don’t want to fill my hard drive with junk just to make sure there’s really no space left. What I want is to simulate this situation withing a particular process (actually, a PHP app).

事实上,暂时禁止磁盘写入进程必须是足够的。

Indeed, temporarily prohibiting disk writes to a process must be enough.

什么是做最简单的方法?我使用的是Mac OS X 10.6.2与内置Apache / PHP包。谢谢你。

What’s the easiest way to do this? I’m using Mac OS X 10.6.2 with built-in Apache/PHP bundle. Thanks.

修改:磁盘空间检查,不会是可靠,因为它可以改变任何时候。许多网页同时被处理。可以有检查时,足够的自由空间,但没有按你实际写东西的那一刻。此外,检查磁盘可用空间将需要改变code无处不在我写的文件,这是不是我想要的。最后,这种解决方案:-)究竟什么我试图测试相反:怎么我的应用程序的行为时,它可以不写了。

Edit: Disk free space check is not going to be reliable since it can change any moment. Many pages are being served simultaneously. There can be enough free space when checking, but none by the moment you actually write something. Also, checking for disk free space will require changing the code everywhere I write a file, which is not what I want :-) Finally, this solution is exactly the opposite of what I’m trying to test: how my app will behave when it cannot write any more.

推荐答案

我敢打赌,你还可以创建与大小的文件系统自己的.dmg文件...说的2Mb和写入。如果一切正常,那么它是超简单的测试 - 你只安装它,并切换路径进行测试。如果伤害是足够小,你很可能甚至把它上传到源头控制。

I bet you could also create your own .dmg file with file system of size ... say 2Mb and write to it. If this works, then it is super-easy for testing - you just mount it and switch the path for testing. If the dmg is small enough, you could probably even upload it to the source control.

这篇关于模拟没有可用磁盘空间的情况最简单的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆