diff mbox

[2/3] acpi: s3: Add support to suspend by generating KEY_SLEEP (LP: #1339588)

Message ID 1405066855-17918-2-git-send-email-kengyu@canonical.com
State Rejected
Headers show

Commit Message

Keng-Yu Lin July 11, 2014, 8:20 a.m. UTC
When run `fwts s3 --s3-sleep-key`, fwts calls acpi_fakekey
to generate KEY_SLEEP rather than calling `pm-suspend` directly.

Signed-off-by: Keng-Yu Lin <kengyu@canonical.com>
---
 src/acpi/s3/s3.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c
index e5b6ef1..69f526b 100644
--- a/src/acpi/s3/s3.c
+++ b/src/acpi/s3/s3.c
@@ -19,6 +19,7 @@ 
 #include <getopt.h>
 
 #include "fwts.h"
+#include "../../../config.h"
 
 #ifdef FWTS_ARCH_INTEL
 
@@ -46,6 +47,8 @@  static bool s3_min_max_delay = false;
 static float s3_suspend_time = 15.0;	/* Maximum allowed suspend time */
 static float s3_resume_time = 15.0;	/* Maximum allowed resume time */
 static bool s3_hybrid = false;
+static bool s3_sleep_key = false;
+static char acpi_fakekey_sleep[PATH_MAX];
 
 static int s3_init(fwts_framework *fw)
 {
@@ -57,6 +60,8 @@  static int s3_init(fwts_framework *fw)
 		return FWTS_ERROR;
 	}
 
+	snprintf(acpi_fakekey_sleep, PATH_MAX, "%s/%s %d\n", LIBEXECDIR, "acpi_fakekey", 142);
+
 	return FWTS_OK;
 }
 
@@ -109,7 +114,13 @@  static int s3_do_suspend_resume(fwts_framework *fw,
 	time(&t_start);
 	(void)fwts_klog_write(fw, "Starting fwts suspend\n");
 	(void)fwts_klog_write(fw, FWTS_SUSPEND "\n");
-	(void)fwts_exec(command, &status);
+
+	if (s3_sleep_key) {
+		(void)fwts_exec(acpi_fakekey_sleep, &status);
+	}
+	else
+		(void)fwts_exec(command, &status);
+
 	(void)fwts_klog_write(fw, FWTS_RESUME "\n");
 	(void)fwts_klog_write(fw, "Finished fwts resume\n");
 	time(&t_end);
@@ -504,6 +515,8 @@  static int s3_options_handler(fwts_framework *fw, int argc, char * const argv[],
 		case 10:
 			s3_hybrid = true;
 			break;
+		case 11:
+			s3_sleep_key = true;
 		}
 	}
 	return FWTS_OK;
@@ -521,6 +534,7 @@  static fwts_option s3_options[] = {
 	{ "s3-suspend-time",	"", 1, "Maximum expected suspend time in seconds, e.g. --s3-suspend-time=3.5" },
 	{ "s3-resume-time", 	"", 1, "Maximum expected resume time in seconds, e.g. --s3-resume-time=5.1" },
 	{ "s3-hybrid",		"", 0, "Run S3 with hybrid sleep, i.e. saving system states as S4 does." },
+	{ "s3-sleep-key",	"", 0, "Run S3 by generating the sleep key event ." },
 	{ NULL, NULL, 0, NULL }
 };