summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/snowball_defconfig8
-rw-r--r--kernel/runtest/snowball54
-rw-r--r--kernel/testcases/Makefile8
-rw-r--r--kernel/testcases/l3g4200d/Makefile21
-rw-r--r--kernel/testcases/l3g4200d/sensor_l3g4200d.c254
-rw-r--r--kernel/testcases/lps001wp_prs/Makefile21
-rw-r--r--kernel/testcases/lps001wp_prs/sensor_lps001wp_prs.c302
-rw-r--r--kernel/testcases/lsm303dlh/Makefile21
-rw-r--r--kernel/testcases/lsm303dlh/sensor_lsm303dlh.c557
-rw-r--r--kernel/testcases/proximity/Makefile21
-rw-r--r--kernel/testcases/proximity/prox_sfh7741.c206
11 files changed, 1465 insertions, 8 deletions
diff --git a/config/snowball_defconfig b/config/snowball_defconfig
index ffce626..63c4c7b 100644
--- a/config/snowball_defconfig
+++ b/config/snowball_defconfig
@@ -23,10 +23,10 @@ CONFIG_LTP_DMA=y
# CONFIG_LTP_EMMC_FILESYSTEM_MMC_VALIDATION_LTP is not set
# CONFIG_LTP_MSP is not set
# CONFIG_LTP_ALS is not set
-# CONFIG_LTP_LSM303DLH is not set
-# CONFIG_LTP_LPS001WP is not set
-# CONFIG_LTP_L3G4200D is not set
-# CONFIG_LTP_PROXIMITY is not set
+CONFIG_LTP_LSM303DLH=y
+CONFIG_LTP_LPS001WP=y
+CONFIG_LTP_L3G4200D=y
+CONFIG_LTP_PROXIMITY=y
# CONFIG_LTP_POWER is not set
# CONFIG_LTP_TEE is not set
# CONFIG_LTP_TIMER is not set
diff --git a/kernel/runtest/snowball b/kernel/runtest/snowball
new file mode 100644
index 0000000..6a80577
--- /dev/null
+++ b/kernel/runtest/snowball
@@ -0,0 +1,54 @@
+# DMA **************************************************************************************************
+DMA-Test22:Sendandreceive32bytebuffer dma -n 22
+DMA-Test1:Sendandreceive1bytebuffer dma -n 1
+DMA-Test2:Sendandreceive1kbuffer dma -n 2
+DMA-Test3:scatter-gatterbuffer dma -n 3
+DMA-Test4:scatter-gatterbuffer dma -n 4
+DMA-Test6:scatter-gatter buffer dma -n 6
+DMA-Test7:scatter-gatter buffer dma -n 7
+DMA-Test8:scatter-gatter buffer dma -n 8
+DMA-Test21:scatter-gatter buffer dma -n 21
+DMA-Test15:Sendandreceive1-4bytesbuffer dma -n 15
+DMA-Test16:Sendandreceive1-4bytesbuffer dma -n 16
+DMA-Test17:Sendandreceive1-4bytesbuffer dma -n 17
+DMA-Test18:Testtotransferalogicaljob<br>with>64links(Outoflclaspacethen dma -n 18
+DMA-Test19:Link2jobsinhwafterfirstjob<br>hasstarted(physical) dma -n 19
+DMA-Test20:Sendandreceive1-4bytesbuffer dma -n 20
+DMA-Test21:Link10jobsinhwafterfirstjobhas<br>started(physical),slowly dma -n 21
+DMA-Test55:Link2jobsinhwbeforestarttransfer(physical) dma -n 55
+DMA-Test56:Link2jobsinhwafterfirstjobhas<br>started(physical) dma -n 56
+DMA-Test57:Link2jobsinhwafterfirstjobhas<br>started(physical) dma -n 58
+DMA-Test58:Link10jobsinhwafterfirstjobhas<br>started(physical) dma -n 59
+DMA-Test59:Link10jobsinhwafterfirstjobhas<br>started(physical) dma -n 59
+DMA-Test60:Link10jobsinhwafterfirstjobhas<br>started(physical) dma -n 60
+DMA-Test61:Link2jobsinhwbeforestarttransfer(logical) dma -n 61
+DMA-Test62:Link2jobsinhwafterfirstjobhas<br>started(logical) dma -n 62
+DMA-Test63:Testtotransferalogicaljob<br>with>64links(Outoflclaspacethen. dma -n 63
+DMA-Test64:Testtotransferalogicaljob<br>with>124links(Outoflclaspacethen. dma -n 64
+DMA-Test65:Testallocate480llilongjobs<br>beforestarting dma -n 65
+DMA-Test66:Link10jobsinhwafterfirstjobhas<br>started(logical) dma -n 66
+DMA-Test67:Link10jobsinhwafterfirstjobhas<br>started(logical),nolinks dma -n 67
+DMA-Test68:Link10jobsinhwafterfirstjobhas<br>started(logical),slowly dma -n 68
+# long running test cases
+DMA-Test26:ToTestscatter-gatterbuffer dma -n 26
+DMA-Test7:ToTestscatter-gatterbuffer dma -n 7
+DMA-Test32:ToTestscatter-gatterbuffer dma -n 32
+DMA-Test33:ToTestscatter-gatterbuffer dma -n 33
+DMA-Test5:ToTestscatter-gatterbuffer dma -n 5
+DMA-Test34:ToTestscatter-gatterbuffer dma -n 34
+DMA-Test27:ToTestscatter-gatterbuffer dma -n 27
+DMA-Test28:ToTestscatter-gatterbuffer dma -n 28
+DMA-Test29:ToTestscatter-gatterbuffer dma -n 29
+
+# LSM303DLH********************************************************************************************************
+sensor_lsm303dlh:Tocheckifthemeasuredproximityvalue<br>fromproximitysensorfallsinallowedrange sensor_lsm303dlh
+
+# L3G4200D*********************************************************************************************************
+sensor_l3g4200d:Tocheckifx,yandzvaluesofaccelerometer<br>andmagnetometersensorsarevalid sensor_l3g4200d
+
+# PROXIMITY********************************************************************************************************
+prox_sfh7741:Tocheckifthex<br>yandzaxisvaluesofgyroscopesensorarevalid prox_sfh7741
+
+# LPS001WP********************************************************************************************************
+sensor_lps001wp_prs:Tocheckifthemeasuredpressurevalue<br>frompressuesensorfallsinallowedrange sensor_lps001wp_prs
+
diff --git a/kernel/testcases/Makefile b/kernel/testcases/Makefile
index 72931da..0c50472 100644
--- a/kernel/testcases/Makefile
+++ b/kernel/testcases/Makefile
@@ -28,10 +28,10 @@ obj-$(CONFIG_LTP_DMA) += dma/
#obj-$(CONFIG_LTP_EMMC_FILESYSTEM_MMC_VALIDATION_LTP) += emmc_filesystem_mmc_Validation_LTP/
#obj-$(CONFIG_LTP_MSP) += msp/
#obj-$(CONFIG_LTP_ALS) += als/
-#obj-$(CONFIG_LTP_LSM303DLH) += lsm303dlh/
-#obj-$(CONFIG_LTP_LPS001WP) += lps001wp_prs/
-#obj-$(CONFIG_LTP_L3G4200D) += l3g4200d/
-#obj-$(CONFIG_LTP_PROXIMITY) += proximity/
+obj-$(CONFIG_LTP_LSM303DLH) += lsm303dlh/
+obj-$(CONFIG_LTP_LPS001WP) += lps001wp_prs/
+obj-$(CONFIG_LTP_L3G4200D) += l3g4200d/
+obj-$(CONFIG_LTP_PROXIMITY) += proximity/
#obj-$(CONFIG_LTP_PWRMGMT) += pwrmgmt/
#obj-$(CONFIG_LTP_TEE) += tee/
#obj-$(CONFIG_LTP_HIGHRES_TIMER) += highres_timer/
diff --git a/kernel/testcases/l3g4200d/Makefile b/kernel/testcases/l3g4200d/Makefile
new file mode 100644
index 0000000..6e128bc
--- /dev/null
+++ b/kernel/testcases/l3g4200d/Makefile
@@ -0,0 +1,21 @@
+ifeq ($(KERNELRELEASE),)
+LTP_DIR = $(abspath ../../../)
+LTP_FULL = $(LTP_DIR)/tempdir/ltp-full
+
+CFLAGS+= -I$(LTP_FULL)/include -I./include
+LOADLIBES+= -L$(LTP_FULL)/lib -lltp
+
+SRCS=$(wildcard *.c)
+TARGETS=$(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+ @for i in $(TARGETS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(TARGETS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+ @for i in $(SCRIPTS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(SCRIPTS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+
+clean:
+ rm -f $(TARGETS)
+endif
diff --git a/kernel/testcases/l3g4200d/sensor_l3g4200d.c b/kernel/testcases/l3g4200d/sensor_l3g4200d.c
new file mode 100644
index 0000000..30f50b1
--- /dev/null
+++ b/kernel/testcases/l3g4200d/sensor_l3g4200d.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2011 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ *
+ * Author: 2011, Chethan Krishna N <chethan.krishna@stericsson.com>
+ */
+
+
+/******************************************************************************/
+/* Description: Test x, y and z axis values from gyroscope driver.
+/*
+/* Test Assertion and Strategy: Assert if all three axes data is valid.
+/*
+/******************************************************************************/
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Extern Global Variables */
+extern int Tst_count; /* counter for tst_xxx routines. */
+extern char *TESTDIR; /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "l3g4200d"; /* test program identifier. */
+
+/* total number of tests in this file. */
+int TST_TOTAL = 1;
+
+#define INVALID_DATA_READ -1
+#define VALID_DATA 0
+
+char *gyr_filepath = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0068/gyrodata";
+char *gyr_filepath_activate = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0068/powermode";
+char *gyr_filepath_range = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0068/range";
+char *gyr_filepath_rate = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0068/datarate";
+char *gyr_filepath_temp = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0068/gyrotemp";
+
+int gyr_set_properties()
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ f = fopen(gyr_filepath_rate, "w");
+ if (f == NULL)
+ return -1;
+
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+
+ f = fopen(gyr_filepath_range, "w");
+ if (f == NULL)
+ return -1;
+
+ if (fputc((int)'0', f) ==EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+
+ return val;
+}
+
+int get_val(char *fname)
+{
+ FILE *f;
+ int data[3], ret;
+
+ f = fopen(fname, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%8x:%8x:%8x", &data[0], &data[1], &data[2]) != 3)
+ ret = INVALID_DATA_READ;
+ else
+ ret = VALID_DATA;
+
+ fclose(f);
+ return ret;
+}
+
+int gyr_get_properties()
+{
+ FILE *f;
+ int data;
+ int ret = 4;
+
+ /* read powermode */
+ f = fopen(gyr_filepath_activate, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* read range */
+ f = fopen(gyr_filepath_range, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* show datarate */
+ f = fopen(gyr_filepath_rate, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* show gyrotemp */
+ f = fopen(gyr_filepath_temp, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ error:
+ fclose(f);
+
+ return ret;
+}
+
+int set_val()
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ /* Before acrivating device try writting to rate,
+ * range & read value to cover error cases.
+ */
+ gyr_set_properties();
+ /*Read output data value */
+ get_val(gyr_filepath);
+
+ f = fopen(gyr_filepath_activate, "w");
+ if (f == NULL)
+ return -1;
+
+ /* Activate L3G4200D device */
+ if (fputc((int)'1', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+ return val;
+}
+
+int main(int argc, const char **argv)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+
+ /***************************************************************
+ * parse standard options
+ ***************************************************************/
+ if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /***************************************************************
+ * check looping state if -c option given
+ ***************************************************************/
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+
+ /***************************************************************
+ * only perform functional verification if flag set (-f not given)
+ ***************************************************************/
+ if (STD_FUNCTIONAL_TEST) {
+
+ for (Tst_count = 0; Tst_count < TST_TOTAL;) {
+
+ switch (Tst_count) {
+ case 0:
+ TEST(set_val());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error when activating gyroscope,"
+ "confirm hardware presence TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. FilePath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, gyr_filepath_activate, TCID, __FILE__);
+
+ TEST(gyr_set_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error setting gyroscope properties,"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+
+ TEST(get_val(gyr_filepath));
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == INVALID_DATA_READ) {
+ tst_resm(TFAIL, "Functional test %d failed. XYZ values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. Filepath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, gyr_filepath, TCID, __FILE__);
+ }
+
+ TEST(gyr_get_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN > 0) {
+ tst_resm(TFAIL, "Functional test %d failed. gyro property values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+ }
+ break;
+ }
+ }
+ }
+ tst_exit();
+ return 0;
+ }
+}
diff --git a/kernel/testcases/lps001wp_prs/Makefile b/kernel/testcases/lps001wp_prs/Makefile
new file mode 100644
index 0000000..6e128bc
--- /dev/null
+++ b/kernel/testcases/lps001wp_prs/Makefile
@@ -0,0 +1,21 @@
+ifeq ($(KERNELRELEASE),)
+LTP_DIR = $(abspath ../../../)
+LTP_FULL = $(LTP_DIR)/tempdir/ltp-full
+
+CFLAGS+= -I$(LTP_FULL)/include -I./include
+LOADLIBES+= -L$(LTP_FULL)/lib -lltp
+
+SRCS=$(wildcard *.c)
+TARGETS=$(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+ @for i in $(TARGETS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(TARGETS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+ @for i in $(SCRIPTS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(SCRIPTS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+
+clean:
+ rm -f $(TARGETS)
+endif
diff --git a/kernel/testcases/lps001wp_prs/sensor_lps001wp_prs.c b/kernel/testcases/lps001wp_prs/sensor_lps001wp_prs.c
new file mode 100644
index 0000000..6e13f0d
--- /dev/null
+++ b/kernel/testcases/lps001wp_prs/sensor_lps001wp_prs.c
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 2011 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ *
+ * Author: 2011, Naga Radhesh Y <naga.radheshy@stericsson.com>
+ */
+
+
+/******************************************************************************/
+/* Description: Test pressure and temperature values from LPS001WP
+* driver.
+*
+* Test Assertion and Strategy: Assert if data is valid.
+*
+******************************************************************************/
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Extern Global Variables */
+extern int Tst_count; /* counter for tst_xxx routines. */
+extern char *TESTDIR; /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "lps001wp"; /* test program identifier. */
+
+/* total number of tests in this file. */
+int TST_TOTAL = 1;
+
+#define INVALID_DATA_READ -1
+#define VALID_DATA 0
+
+char *path_prs_enable = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/enable";
+char *path_prs_pollrate = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/pollrate_ms";
+char *path_prs_diffenable = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/diff_enable";
+char *path_prs_ref = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/press_reference";
+char *path_prs_lowpow_enable = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/lowpow_enable";
+char *path_prs_pressdata = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/press_data";
+char *path_prs_tempdata = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/temp_data";
+char *path_prs_deltapresdata = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/deltapr_data";
+char *path_prs_regval = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/reg_value";
+char *path_prs_regaddr = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-005c/reg_addr";
+
+int get_val()
+{
+ FILE *f;
+ int data, ret;
+
+ f = fopen(path_prs_pressdata, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ ret = INVALID_DATA_READ;
+ else
+ ret = VALID_DATA;
+
+ close(f);
+
+ f = fopen(path_prs_tempdata, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ ret = INVALID_DATA_READ;
+ else
+ ret = VALID_DATA;
+
+ close(f);
+
+ f = fopen(path_prs_deltapresdata, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ ret = INVALID_DATA_READ;
+ else
+ ret = VALID_DATA;
+
+ close(f);
+ return ret;
+}
+
+int prs_set_properties()
+{
+ FILE *f;
+ unsigned long val = 0;
+
+ f = fopen(path_prs_pollrate, "w");
+ if (f == NULL)
+ return -1;
+
+ /*write sampling rate value */
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ if (fputs("500", f) == EOF)
+ val = EOF;
+ fclose(f);
+
+ /*write Diff enable value */
+ f = fopen(path_prs_diffenable, "w");
+ if (f == NULL)
+ return -1;
+
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ fclose(f);
+
+ /*write ref pressure value */
+ f = fopen(path_prs_ref, "w");
+ if (f == NULL)
+ return -1;
+
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ fclose(f);
+
+ /*write ref pressure value */
+ f = fopen(path_prs_lowpow_enable, "w");
+ if (f == NULL)
+ return -1;
+
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ fclose(f);
+
+ /*write ref pressure value */
+ f = fopen(path_prs_regaddr, "w");
+ if (f == NULL)
+ return -1;
+
+ if (fputs("0x34", f) == EOF)
+ val = EOF;
+ fclose(f);
+
+ return val;
+}
+
+
+int prs_set_mode()
+{
+ FILE *f;
+ unsigned long val = 0;
+
+ /* Read all the sysfs nodes to cover
+ * code flow in error case scenarios
+ */
+ prs_set_properties();
+ get_val();
+
+ f = fopen(path_prs_enable, "w");
+ if (f == NULL)
+ return -1;
+
+ /* Activate LSM device */
+ if (fputc((int)'1', f) == EOF)
+ val = EOF;
+ fclose(f);
+ return val;
+}
+
+int prs_get_properties()
+{
+ FILE *f;
+ int data;
+ unsigned long val = 0;
+
+ f = fopen(path_prs_pollrate, "r");
+ if (f == NULL)
+ return -1;
+
+ /*read sampling rate value */
+ if (fscanf(f, "%d", &data) != 1)
+ val = EOF;
+ fclose(f);
+
+ /*read Diff enable value */
+ f = fopen(path_prs_diffenable, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ val = EOF;
+ fclose(f);
+
+ /*read ref pressure value */
+ f = fopen(path_prs_ref, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ val = EOF;
+ fclose(f);
+
+ /*read ref pressure value */
+ f = fopen(path_prs_lowpow_enable, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ val = EOF;
+ fclose(f);
+
+ /*read ref pressure value */
+ f = fopen(path_prs_regval, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ val = EOF;
+ fclose(f);
+
+ return val;
+}
+
+int main(int argc, const char **argv)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+
+ /***************************************************************
+ * parse standard options
+ ***************************************************************/
+ if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /***************************************************************
+ * check looping state if -c option given
+ ***************************************************************/
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+
+ /***************************************************************
+ * only perform functional verification if flag set (-f not given)
+ ***************************************************************/
+ if (STD_FUNCTIONAL_TEST) {
+
+ for (Tst_count = 0; Tst_count < TST_TOTAL;) {
+
+ switch (Tst_count) {
+ case 0:
+ TEST(prs_set_mode());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error activating pres sensor,"
+ "confirm hardware presence. TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. FilePath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, path_prs_enable, TCID, __FILE__);
+
+ TEST(prs_set_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error setting pres sensor properties,"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+
+ TEST(get_val());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == INVALID_DATA_READ) {
+ tst_resm(TFAIL, "Functional test %d failed. pres sensor values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. Filepath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, path_prs_pressdata, TCID, __FILE__);
+ }
+
+ TEST(prs_get_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN > 0) {
+ tst_resm(TFAIL, "Functional test %d failed. pres sensor values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+ }
+ break;
+ }
+ }
+ }
+ tst_exit();
+ return 0;
+ }
+}
diff --git a/kernel/testcases/lsm303dlh/Makefile b/kernel/testcases/lsm303dlh/Makefile
new file mode 100644
index 0000000..6e128bc
--- /dev/null
+++ b/kernel/testcases/lsm303dlh/Makefile
@@ -0,0 +1,21 @@
+ifeq ($(KERNELRELEASE),)
+LTP_DIR = $(abspath ../../../)
+LTP_FULL = $(LTP_DIR)/tempdir/ltp-full
+
+CFLAGS+= -I$(LTP_FULL)/include -I./include
+LOADLIBES+= -L$(LTP_FULL)/lib -lltp
+
+SRCS=$(wildcard *.c)
+TARGETS=$(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+ @for i in $(TARGETS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(TARGETS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+ @for i in $(SCRIPTS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(SCRIPTS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+
+clean:
+ rm -f $(TARGETS)
+endif
diff --git a/kernel/testcases/lsm303dlh/sensor_lsm303dlh.c b/kernel/testcases/lsm303dlh/sensor_lsm303dlh.c
new file mode 100644
index 0000000..e6c0b9d
--- /dev/null
+++ b/kernel/testcases/lsm303dlh/sensor_lsm303dlh.c
@@ -0,0 +1,557 @@
+/*
+ * Copyright (C) 2011 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ *
+ * Author: 2011, Chethan Krishna N <chethan.krishna@stericsson.com>
+ */
+
+
+/******************************************************************************/
+/* Description: Test x, y and z axis values from acceleromter and magnetometer
+* drivers.
+*
+* Test Assertion and Strategy: Assert if all three axes data is valid.
+*
+******************************************************************************/
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Extern Global Variables */
+extern int Tst_count; /* counter for tst_xxx routines. */
+extern char *TESTDIR; /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "lsm303dlh"; /* test program identifier. */
+
+/* total number of tests in this file. */
+int TST_TOTAL = 1;
+int id;
+
+#define INVALID_DATA_READ -1
+#define VALID_DATA 0
+#define MAX_LENGTH 100
+
+char acc_filepath[MAX_LENGTH] = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0018/data";
+char acc_filepath_activate[MAX_LENGTH] = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0018/mode";
+char acc_filepath_range[MAX_LENGTH] = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0018/range";
+char acc_filepath_sleepwake[MAX_LENGTH] = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0018/sleep_wake";
+char acc_filepath_id[MAX_LENGTH] = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0018/id";
+char acc_filepath_rate[MAX_LENGTH] = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-0018/rate";
+
+char *mag_filepath_range = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-001e/range";
+char *mag_filepath = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-001e/data";
+char *mag_filepath_activate = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-001e/mode";
+char *mag_filepath_rate = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-001e/rate";
+char *mag_filepath_gain = "/sys/devices/platform/nmk-i2c.2/i2c-2/2-001e/gain";
+
+int get_val(char *fname)
+{
+ FILE *f;
+ int data[3], ret;
+
+ f = fopen(fname, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%8x:%8x:%8x", &data[0], &data[1], &data[2]) != 3)
+ ret = INVALID_DATA_READ;
+ else
+ ret = VALID_DATA;
+
+ fclose(f);
+ return ret;
+}
+
+int acc_set_val()
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ /* Before acrivating device try writting to rate,
+ * range and sleepwake & read out data to cover error cases.
+ */
+ if(id == 50) {
+ /*write sampling rate value */
+ f = fopen(acc_filepath_rate, "w");
+ if (f == NULL)
+ return -1;
+ fputc((int)'0', f);
+ fclose(f);
+
+ /*write sampling sleepwake value */
+ f = fopen(acc_filepath_sleepwake, "w");
+ if (f == NULL)
+ return -1;
+ fputc((int)'0', f);
+ fclose(f);
+ }
+
+ /*write range value */
+ f = fopen(acc_filepath_range, "w");
+ if (f == NULL)
+ return -1;
+ fputc((int)'1', f);
+ fclose(f);
+
+ /*read the output data*/
+ get_val(acc_filepath);
+
+ f = fopen(acc_filepath_activate, "w");
+ if (f == NULL)
+ return -1;
+
+ /* Activate LSM device */
+ if (fputc((int)'1', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+ return val;
+}
+
+int acc_set_properties()
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ if (id == 50) {
+ f = fopen(acc_filepath_rate, "w");
+ if (f == NULL)
+ return -1;
+
+ /*write sampling rate value */
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+
+ f = fopen(acc_filepath_sleepwake, "w");
+ if (f == NULL)
+ return -1;
+
+ /*write sampling sleepwake value */
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+ }
+
+ f = fopen(acc_filepath_range, "w");
+ if (f == NULL)
+ return -1;
+
+ /*write all the range value specified in datasheet*/
+ if (fputc((int)'1', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'2', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'3', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+
+ return val;
+}
+
+int mag_set_properties()
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ f = fopen(mag_filepath_rate, "w");
+ if (f == NULL)
+ return -1;
+
+ /*write sampling rate value */
+ if (fputc((int)'4', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+
+ f = fopen(mag_filepath_range, "w");
+ if (f == NULL)
+ return -1;
+
+ /*write range value */
+ if (fputc((int)'1', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'2', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'3', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'5', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'6', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+
+ if (fputc((int)'7', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+ if (fputc((int)'8', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fflush(f);
+ if (fputc((int)'4', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+ fclose(f);
+
+ return val;
+}
+
+int mag_set_val()
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ /* Before acrivating device try writting to rate,
+ * range & read out value to cover error cases.
+ */
+ /*write sampling rate value */
+ f = fopen(mag_filepath_rate, "w");
+ if (f == NULL)
+ return -1;
+ fputc((int)'4', f);
+ fclose(f);
+
+ /*write range value */
+ f = fopen(mag_filepath_range, "w");
+ if (f == NULL)
+ return -1;
+
+ fputc((int)'1', f);
+ fclose(f);
+
+ /*read the output data*/
+ get_val(mag_filepath);
+
+ f = fopen(mag_filepath_activate, "w");
+ if (f == NULL)
+ return -1;
+
+ /* Activate LSM device */
+ if (fputc((int)'0', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+ return val;
+}
+
+int acc_get_properties()
+{
+ FILE *f;
+ int data;
+ int ret = 4;
+
+ /* read power mode */
+ f = fopen(acc_filepath_activate, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* read range */
+ f = fopen(acc_filepath_range, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ if(id == 50) {
+ fclose(f);
+ /* read data rate */
+ f = fopen(acc_filepath_rate, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* read sleep-to-wake */
+ f = fopen(acc_filepath_sleepwake, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data) != 1)
+ goto error;
+ else
+ ret--;
+ }
+ else
+ ret -=2;
+
+ error:
+ fclose(f);
+
+ return ret;
+}
+
+int mag_get_properties()
+{
+ FILE *f;
+ int data[3];
+ int ret = 4;
+
+ /* read power mode */
+ f = fopen(mag_filepath_activate, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data[0]) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* read range */
+ f = fopen(mag_filepath_range, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data[0]) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* read data rate */
+ f = fopen(mag_filepath_rate, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &data[0]) != 1)
+ goto error;
+ else
+ ret--;
+ fclose(f);
+
+ /* read gain */
+ f = fopen(mag_filepath_gain, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%8x:%8x:%8x", &data[0], &data[1], &data[2]) != 3)
+ goto error;
+ else
+ ret--;
+
+ error:
+ fclose(f);
+
+ return ret;
+}
+
+int check_acc_devid()
+{
+ FILE *f = NULL;
+ int ret = 0;
+ f = fopen(acc_filepath, "r");
+ if (f == NULL) {
+ f = fopen("/sys/devices/platform/nmk-i2c.2/i2c-2/2-0019/data", "r");
+ if (f == NULL)
+ return -1;
+ strncpy(acc_filepath,"/sys/devices/platform/nmk-i2c.2/i2c-2/2-0019/data",(MAX_LENGTH -1));
+ strncpy(acc_filepath_activate,"/sys/devices/platform/nmk-i2c.2/i2c-2/2-0019/mode",(MAX_LENGTH -1));
+ strncpy(acc_filepath_range,"/sys/devices/platform/nmk-i2c.2/i2c-2/2-0019/range",(MAX_LENGTH -1));
+ strncpy(acc_filepath_rate,"/sys/devices/platform/nmk-i2c.2/i2c-2/2-0019/rate",(MAX_LENGTH -1));
+ strncpy(acc_filepath_sleepwake,"/sys/devices/platform/nmk-i2c.2/i2c-2/2-0019/sleep_wake",(MAX_LENGTH -1));
+ strncpy(acc_filepath_id,"/sys/devices/platform/nmk-i2c.2/i2c-2/2-0019/id",(MAX_LENGTH -1));
+ }
+ fclose(f);
+ /* read id */
+ f = fopen(acc_filepath_id, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%d", &id) != 1)
+ ret = -1;
+ fclose(f);
+ return ret;
+}
+
+int main(int argc, const char **argv)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+
+ /***************************************************************
+ * parse standard options
+ ***************************************************************/
+ if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /***************************************************************
+ * check looping state if -c option given
+ ***************************************************************/
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+
+ /***************************************************************
+ * only perform functional verification if flag set (-f not given)
+ ***************************************************************/
+ if (STD_FUNCTIONAL_TEST) {
+
+ for (Tst_count = 0; Tst_count < TST_TOTAL;) {
+
+ switch (Tst_count) {
+ case 0:
+ TEST(check_acc_devid());
+ TEST(acc_set_val());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error activating accelerometer,"
+ "confirm hardware presence. TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. FilePath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, acc_filepath_activate, TCID, __FILE__);
+
+ TEST(acc_set_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error setting accelerometer properties,"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+
+ TEST(get_val(acc_filepath));
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == INVALID_DATA_READ) {
+ tst_resm(TFAIL, "Functional test %d failed. Accelerometer XYZ values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. Filepath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, acc_filepath, TCID, __FILE__);
+ }
+
+ TEST(mag_set_val());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error when activating magnetometer,"
+ "confirm hardware presence. TCID: %s File: %s" , Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. FilePath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, acc_filepath_activate, TCID, __FILE__);
+
+ TEST(mag_set_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error setting magnetometer properties,"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+
+ TEST(get_val(mag_filepath));
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == INVALID_DATA_READ) {
+ tst_resm(TFAIL, "Functional test %d failed. Magnetometer XYZ values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. Filepath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, mag_filepath, TCID, __FILE__);
+ }
+
+ TEST(acc_get_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN > 0) {
+ tst_resm(TFAIL, "Functional test %d failed. accelerometer property values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+ }
+
+ TEST(mag_get_properties());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN > 0) {
+ tst_resm(TFAIL, "Functional test %d failed. magnetometer property values not read completely"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. TCID: %s File: %s\n", Tst_count, TCID, __FILE__);
+ }
+ break;
+ }
+ }
+ }
+ tst_exit();
+ return 0;
+ }
+}
diff --git a/kernel/testcases/proximity/Makefile b/kernel/testcases/proximity/Makefile
new file mode 100644
index 0000000..6e128bc
--- /dev/null
+++ b/kernel/testcases/proximity/Makefile
@@ -0,0 +1,21 @@
+ifeq ($(KERNELRELEASE),)
+LTP_DIR = $(abspath ../../../)
+LTP_FULL = $(LTP_DIR)/tempdir/ltp-full
+
+CFLAGS+= -I$(LTP_FULL)/include -I./include
+LOADLIBES+= -L$(LTP_FULL)/lib -lltp
+
+SRCS=$(wildcard *.c)
+TARGETS=$(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+ @for i in $(TARGETS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(TARGETS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+ @for i in $(SCRIPTS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done
+ @for i in $(SCRIPTS); do install $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done
+
+clean:
+ rm -f $(TARGETS)
+endif
diff --git a/kernel/testcases/proximity/prox_sfh7741.c b/kernel/testcases/proximity/prox_sfh7741.c
new file mode 100644
index 0000000..49a07c4
--- /dev/null
+++ b/kernel/testcases/proximity/prox_sfh7741.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2011 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ *
+ * Author: 2011, Chethan Krishna N <chethan.krishna@stericsson.com>
+ */
+
+
+/******************************************************************************/
+/* Description: Test if proximity value from proximity driver is reasonable
+/*
+/* Test Assertion and Strategy: Assert if value is within range.
+/******************************************************************************/
+
+/* Harness Specific Include Files. */
+#include "test.h"
+#include "usctest.h"
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <sys/time.h>
+#include <linux/input.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Extern Global Variables */
+extern int Tst_count; /* counter for tst_xxx routines. */
+extern char *TESTDIR; /* temporary dir created by tst_tmpdir() */
+
+/* Global Variables */
+char *TCID = "prox_sfh7741"; /* test program identifier. */
+
+/* total number of tests in this file. */
+int TST_TOTAL = 1;
+
+#define FISHY_PROXIMITY_VALUE -10
+#define PROXIMITY_NEAR_VALUE 0
+#define PROXIMITY_FAR_VALUE 100000
+
+char *filepath_input = "/dev/input/event0";
+char *filepath = "/sys/devices/platform/sensors1p.0/proximity";
+char *filepath_activate = "/sys/devices/platform/sensors1p.0/proximity_activate";
+
+int set_val()
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ f = fopen(filepath_activate, "w");
+ if (f == NULL)
+ return -1;
+
+ /* Activate Proximity driver */
+ if (fputc((int)'1', f) == EOF)
+ val = EOF;
+ else
+ val = 0;
+
+ fclose(f);
+ return val;
+}
+
+int get_val(char *fname)
+{
+ FILE *f;
+ unsigned long val = -1;
+
+ f = fopen(fname, "r");
+ if (f == NULL)
+ return -1;
+
+ if (fscanf(f, "%ld", &val) > 0) {
+
+ /* Reasonable values */
+ if (val >= PROXIMITY_NEAR_VALUE && val <= PROXIMITY_FAR_VALUE)
+ val = 0;
+ else
+ val = FISHY_PROXIMITY_VALUE;
+ }
+ fclose(f);
+ return val;
+}
+int get_interrupt_val()
+{
+ int fd = -1,retval = -1;
+ fd_set read_set;
+ struct input_event ev;
+ struct timeval tv;
+ int val = -1;
+ int size = sizeof(struct input_event);
+
+ /*Initialise the structures*/
+ memset(&ev, 0x00, sizeof(ev));
+ memset(&tv, 0x00, sizeof(tv));
+ /* open input device */
+ if ((fd = open(filepath_input, O_RDONLY)) == -1)
+ return -1;
+ /*Intialise the read descriptor*/
+ FD_ZERO(&read_set);
+ FD_SET(fd,&read_set);
+ /* Wait up to five seconds. */
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ retval = select(fd+1, &read_set, NULL, NULL, &tv);
+ if (retval > 0 ) {
+ /* FD_ISSET(0, &rfds) will be true. */
+ if (FD_ISSET(fd, &read_set)) {
+ read(fd, &ev, size );
+ if(11 == ev.code) {
+ if (ev.value >= PROXIMITY_NEAR_VALUE && ev.value <= PROXIMITY_FAR_VALUE)
+ val = 0;
+ else
+ val = FISHY_PROXIMITY_VALUE;
+ }
+ }
+ }
+ else if(retval == -1) {
+ return -1;
+ }
+ else {
+ val = 0;
+ }
+ if(fd > 0)
+ close(fd);
+ return val;
+}
+
+
+int main(int argc, const char **argv)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ struct utsname buf;
+
+ /***************************************************************
+ * parse standard options
+ ***************************************************************/
+ if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /***************************************************************
+ * check looping state if -c option given
+ ***************************************************************/
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+
+ /***************************************************************
+ * only perform functional verification if flag set (-f not given)
+ ***************************************************************/
+ if (STD_FUNCTIONAL_TEST) {
+
+ for (Tst_count = 0; Tst_count < TST_TOTAL;) {
+
+ switch (Tst_count) {
+ case 0:
+ uname(&buf);
+ if(strncmp(buf.release,"3.0",3) == 0) {
+ TEST(get_interrupt_val());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == FISHY_PROXIMITY_VALUE) {
+ tst_resm(TFAIL, "Functional test %d failed. proximity value not valid"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. Filepath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, filepath, TCID, __FILE__);
+ }
+ }
+ else {
+ TEST(set_val());
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == EOF)
+ tst_resm(TFAIL, "Functional test %d failed. Error when activating proximity. TCID: %s File: %s"
+ , Tst_count, TCID, __FILE__);
+ else
+ tst_resm(TFAIL, "Functional test %d failed. FilePath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, filepath_activate, TCID, __FILE__);
+
+ TEST(get_val(filepath));
+ if (TEST_RETURN == 0)
+ tst_resm(TPASS, "Functional test %d OK\n", Tst_count);
+ else if (TEST_RETURN == FISHY_PROXIMITY_VALUE) {
+ tst_resm(TFAIL, "Functional test %d failed. proximity value not valid"
+ "TCID: %s File: %s", Tst_count, TCID, __FILE__);
+ } else {
+ tst_resm(TFAIL, "Functional test %d failed. Filepath: %s not found. TCID: %s File: %s\n"
+ , Tst_count, filepath, TCID, __FILE__);
+ }
+ }
+ break;
+ }
+ }
+ }
+ tst_exit();
+ return 0;
+ }
+}