Skip to content

Commit edbc4e6

Browse files
committed
RDK-61088: Replace vendor reboot reason script from shell to C
Reason for change: Added code for Reboot reason Test Procedure: None Risks: P1 Signed-off-by: najeemabegami <najeemabegam.iqbal@sky.uk>
1 parent b4cd16f commit edbc4e6

5 files changed

Lines changed: 20 additions & 18 deletions

File tree

reboot-helper/src/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ librebootnow_la_SOURCES = \
3232
cyclic_reboot.c \
3333
utils.c
3434

35-
librebootnow_la_LIBADD = -lfwutils -lrdkloggers -lrfcapi -lsecure_wrapper
35+
librebootnow_la_LIBADD = -lfwutils -lrdkloggers -lrfcapi -lsecure_wrapper #-lrebootreason
3636

3737
# CLI wrapper binary
3838
bin_PROGRAMS = rebootnow
3939
rebootnow_SOURCES = reboot_main.c
4040
rebootnow_LDADD = librebootnow.la
4141

42-
AM_LDFLAGS = -lrdkloggers -lfwutils -lrfcapi -lsecure_wrapper
42+
AM_LDFLAGS = -lrdkloggers -lfwutils -lrfcapi -lsecure_wrapper #-lrebootreason
4343

4444
bin_PROGRAMS += update-prev-reboot-info
4545
update_prev_reboot_info_SOURCES = \
@@ -55,6 +55,8 @@ update_prev_reboot_info_SOURCES += \
5555
$(srcdir)/rebootmanager-cpc/src/log_parser.c
5656
update_prev_reboot_info_CPPFLAGS = \
5757
-I$(srcdir)/rebootmanager-cpc/include
58+
59+
update_prev_reboot_info_la_LIBADD = -lrebootreason
5860
else
5961
update_prev_reboot_info_SOURCES += \
6062
$(top_srcdir)/reboot-reason-fetcher/src/reboot_reason_classify.c \

reboot-reason-fetcher/include/update-reboot-info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int acquire_lock(const char *lockDir);
118118
int release_lock(const char *lockDir);
119119
int parse_device_properties(EnvContext *ctx);
120120
void free_env_context(EnvContext *ctx);
121-
int get_hardware_reason(const EnvContext *ctx, HardwareReason *hwReason, RebootInfo *info);
121+
int get_hardware_reason(const EnvContext *ctx, HardwareReason *hwReason);
122122
int read_brcm_previous_reboot_reason(HardwareReason *hw);
123123
int detect_kernel_panic(const EnvContext *ctx, PanicInfo *panicInfo);
124124
int check_firmware_failure(const EnvContext *ctx, FirmwareFailure *fwFailure);

reboot-reason-fetcher/src/log_parser.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ int update_reboot_info(const EnvContext *ctx)
114114
return 1;
115115
}
116116

117-
int get_hardware_reason(const EnvContext *ctx, HardwareReason *hwReason, RebootInfo *info)
117+
int get_hardware_reason(const EnvContext *ctx, HardwareReason *hwReason)
118118
{
119-
if (ctx == NULL || hwReason == NULL || info == NULL) {
120-
RDK_LOG(RDK_LOG_ERROR, "LOG.RDK.REBOOTINFO", "get_hardware_reason: invalid argument(s): ctx=%p, hwReason=%p, info=%p",
121-
(const void *)ctx, (void *)hwReason, (void *)info);
119+
if (ctx == NULL || hwReason == NULL) {
120+
RDK_LOG(RDK_LOG_ERROR, "LOG.RDK.REBOOTINFO", "get_hardware_reason: invalid argument(s): ctx=%p, hwReason=%p",
121+
(const void *)ctx, (void *)hwReason);
122122
return ERROR_GENERAL;
123123
}
124124

reboot-reason-fetcher/src/rebootreason_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int main(void)
150150
check_firmware_failure(&ctx, &fwFailure);
151151

152152
RDK_LOG(RDK_LOG_DEBUG,"LOG.RDK.REBOOTINFO","Getting hardware reboot reason for current boot \n");
153-
get_hardware_reason(&ctx, &hwReason, &rebootInfo);
153+
get_hardware_reason(&ctx, &hwReason);
154154

155155
RDK_LOG(RDK_LOG_INFO,"LOG.RDK.REBOOTINFO","Classifying reboot reason \n");
156156
if (classify_reboot_reason(&rebootInfo, &ctx, &hwReason, &panicInfo, &fwFailure) != SUCCESS) {

unittest/reboot_log_parser_gtest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchBrcmPath) {
511511
memset(&info, 0, sizeof(info));
512512
set_hal_test_soc(&ctx, HalTestSoc::Brcm);
513513

514-
int rc = get_hardware_reason(&ctx, &hw, &info);
514+
int rc = get_hardware_reason(&ctx, &hw);
515515
EXPECT_EQ(rc, SUCCESS);
516516
EXPECT_NE(hw.mappedReason[0], '\0');
517517
}
@@ -525,7 +525,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchAmlogicPath) {
525525
memset(&info, 0, sizeof(info));
526526
set_hal_test_soc(&ctx, HalTestSoc::Amlogic);
527527

528-
int rc = get_hardware_reason(&ctx, &hw, &info);
528+
int rc = get_hardware_reason(&ctx, &hw);
529529
EXPECT_EQ(rc, SUCCESS);
530530
EXPECT_STREQ(hw.mappedReason, "UNKNOWN");
531531
}
@@ -539,7 +539,7 @@ TEST_F(LogParserTest, get_hardware_reason_UnknownSocFallsBackToUnknown) {
539539
memset(&info, 0, sizeof(info));
540540
set_hal_test_soc(&ctx, HalTestSoc::Unknown);
541541

542-
int rc = get_hardware_reason(&ctx, &hw, &info);
542+
int rc = get_hardware_reason(&ctx, &hw);
543543
EXPECT_EQ(rc, SUCCESS);
544544
EXPECT_NE(hw.mappedReason[0], '\0');
545545
}
@@ -565,7 +565,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchRtkAliasPath) {
565565
memset(&info, 0, sizeof(info));
566566
set_hal_test_soc(&ctx, HalTestSoc::Realtek);
567567

568-
int rc = get_hardware_reason(&ctx, &hw, &info);
568+
int rc = get_hardware_reason(&ctx, &hw);
569569
EXPECT_EQ(rc, SUCCESS);
570570
EXPECT_STREQ(hw.mappedReason, "UNKNOWN");
571571
}
@@ -579,7 +579,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchMtkPath) {
579579
memset(&info, 0, sizeof(info));
580580
set_hal_test_soc(&ctx, HalTestSoc::Mtk);
581581

582-
int rc = get_hardware_reason(&ctx, &hw, &info);
582+
int rc = get_hardware_reason(&ctx, &hw);
583583
EXPECT_TRUE(rc == SUCCESS || rc == FAILURE || rc == ERROR_GENERAL);
584584
}
585585

@@ -592,7 +592,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchBroadcomAliasPath) {
592592
memset(&info, 0, sizeof(info));
593593
set_hal_test_soc(&ctx, HalTestSoc::Broadcom);
594594

595-
int rc = get_hardware_reason(&ctx, &hw, &info);
595+
int rc = get_hardware_reason(&ctx, &hw);
596596
EXPECT_EQ(rc, SUCCESS);
597597
EXPECT_STREQ(hw.mappedReason, "UNKNOWN");
598598
}
@@ -606,7 +606,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchMediatekAliasPath) {
606606
memset(&info, 0, sizeof(info));
607607
set_hal_test_soc(&ctx, HalTestSoc::Mediatek);
608608

609-
int rc = get_hardware_reason(&ctx, &hw, &info);
609+
int rc = get_hardware_reason(&ctx, &hw);
610610
EXPECT_TRUE(rc == SUCCESS || rc == FAILURE || rc == ERROR_GENERAL);
611611
}
612612

@@ -618,7 +618,7 @@ TEST_F(LogParserTest, get_hardware_reason_EmptySocFallbackPath) {
618618
memset(&hw, 0, sizeof(hw));
619619
memset(&info, 0, sizeof(info));
620620

621-
int rc = get_hardware_reason(&ctx, &hw, &info);
621+
int rc = get_hardware_reason(&ctx, &hw);
622622
EXPECT_EQ(rc, SUCCESS);
623623
EXPECT_NE(hw.mappedReason[0], '\0');
624624
}
@@ -650,7 +650,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchAmlogicUsesReadPath) {
650650
memset(&info, 0, sizeof(info));
651651
set_hal_test_soc(&ctx, HalTestSoc::Amlogic);
652652

653-
EXPECT_EQ(get_hardware_reason(&ctx, &hw, &info), SUCCESS);
653+
EXPECT_EQ(get_hardware_reason(&ctx, &hw), SUCCESS);
654654
EXPECT_STREQ(hw.mappedReason, "UNKNOWN");
655655
EXPECT_EQ(info.reason[0], '\0');
656656
}
@@ -668,7 +668,7 @@ TEST_F(LogParserTest, get_hardware_reason_DispatchMtkUsesReadPath) {
668668
set_hal_test_soc(&ctx, HalTestSoc::Mediatek);
669669
strncpy(info.timestamp, "2026-03-10T11:22:33Z", sizeof(info.timestamp) - 1);
670670

671-
EXPECT_EQ(get_hardware_reason(&ctx, &hw, &info), SUCCESS);
671+
EXPECT_EQ(get_hardware_reason(&ctx, &hw), SUCCESS);
672672
EXPECT_STREQ(hw.mappedReason, "UNKNOWN");
673673
EXPECT_EQ(info.reason[0], '\0');
674674
EXPECT_STREQ(info.timestamp, "2026-03-10T11:22:33Z");

0 commit comments

Comments
 (0)