Skip to contentSkip to conversation

mini-os: put sanity_check() under CONFIG_TEST

PATCH In review Juergen Gross 2 participants 2 messages Jul 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mini-os: put sanity_check() under CONFIG_TEST

Hide the sanity_check() function, as it is used nowhere. By putting it under #ifdef CONFIG_TEST it will stay around, but it won't be included in normal production builds.

Call sanity_check() from the periodic thread of the test app, causing a sanity check every second.

Since any application linked with Mini-OS can't call sanity_check() (there is no EXPORT_SYMBOL for it), there is zero chance of breaking any use case.

---
V2:
- don't remove it, but just hide it (Samuel Thibault)

---
 include/lib.h | 2 ++
 mm.c          | 2 ++
 test.c        | 1 +
 3 files changed, 5 insertions(+)
include/lib.h +2 -0
index abd4e9ab..de67bab0 100644
@@ -152,8 +152,10 @@ do {                                                           \
 
 #define BUG_ON(x) ASSERT(!(x))
 
+#ifdef CONFIG_TEST
 /* Consistency check as much as possible. */
 void sanity_check(void);
+#endif
 
 /* Get own domid. */
 domid_t get_domid(void);
mm.c +2 -0
index 4aa0c6ca..a5d3f5e5 100644
@@ -395,6 +395,7 @@ void fini_mm(void)
 {
 }
 
+#ifdef CONFIG_TEST
 void sanity_check(void)
 {
     int x;
@@ -410,3 +411,4 @@ void sanity_check(void)
         }
     }
 }
+#endif
test.c +1 -0
index 465c54e8..4dd6e260 100644
@@ -185,6 +185,7 @@ static void periodic_thread(void *p)
     {
         gettimeofday(&tv, NULL);
         printk("T(s=%ld us=%ld)\n", tv.tv_sec, tv.tv_usec);
+        sanity_check();
         msleep(1000);
     }
 }
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw

Juergen Gross, le jeu. 25 juil. 2024 08:42:54 +0200, a ecrit:

Quoted 4 lines

Hide the sanity_check() function, as it is used nowhere. By putting it under #ifdef CONFIG_TEST it will stay around, but it won't be included in normal production builds.

Quoted 8 lines

Call sanity_check() from the periodic thread of the test app, causing a sanity check every second.

Since any application linked with Mini-OS can't call sanity_check() (there is no EXPORT_SYMBOL for it), there is zero chance of breaking any use case.

Thanks!

Quoted 56 lines

---
V2:
- don't remove it, but just hide it (Samuel Thibault)

---
 include/lib.h | 2 ++
 mm.c          | 2 ++
 test.c        | 1 +
 3 files changed, 5 insertions(+)
include/lib.h +2 -0
index abd4e9ab..de67bab0 100644
@@ -152,8 +152,10 @@ do {                                                           \
 
 #define BUG_ON(x) ASSERT(!(x))
 
+#ifdef CONFIG_TEST
 /* Consistency check as much as possible. */
 void sanity_check(void);
+#endif
 
 /* Get own domid. */
 domid_t get_domid(void);
mm.c +2 -0
index 4aa0c6ca..a5d3f5e5 100644
@@ -395,6 +395,7 @@ void fini_mm(void)
 {
 }
 
+#ifdef CONFIG_TEST
 void sanity_check(void)
 {
     int x;
@@ -410,3 +411,4 @@ void sanity_check(void)
         }
     }
 }
+#endif
test.c +1 -0
index 465c54e8..4dd6e260 100644
@@ -185,6 +185,7 @@ static void periodic_thread(void *p)
     {
         gettimeofday(&tv, NULL);
         printk("T(s=%ld us=%ld)\n", tv.tv_sec, tv.tv_usec);
+        sanity_check();
         msleep(1000);
     }
 }
Signature · 1 line
2.43.0
Signature · 4 lines
Samuel
`When you say "I wrote a program that crashed Windows", people just stare at
you blankly and say "Hey, I got those with the system, *for free*".'
(By Linus Torvalds)