On 7/10/24 9:00 AM, Shuah Khan wrote:
On 7/10/24 01:55, Alexandre Belloni wrote:
On 10/07/2024 00:43:09-0700, Zhu Jun wrote:
The opened file should be closed before exit, otherwise resource leak will occur that this problem was discovered by code reading
The question is still why should it be closed before exit as it will be closed on exit?
Zhu Jun,
+1 on this. I have responded to your other patches that do the same in other tests. There is no need to make such changes.
thanks, -- Shuah
Yes. What Shuah and Alexandre said. And the same reasoning also applies to memory buffers: they are also released by the kernel at program exit.
This blind adherence to "good programming practices" is not helpful here, because it turns out that selftests are small, short-running, and simple. These are all desirable properties, because remember, there are no tests to verify the selftests, so we rely on keeping them simple and very easy to quickly read and understand.
"Good programming practices" is not a "one approach to all programs" thing.
So adding line count to free something a few lines before program exit, for tiny programs, is actually counter productive in this environment.
Zhu, if you're going to keep working on selftests, I think you would really benefit from some of the literature that goes into the design philosophy for unit tests. Google has the best (and most recent) work IMHO [1], but there are others of course.
[1] Software Engineering at Google (Apr 7, 2020), by Titus Winters
thanks,