Stall warning systems generally function on the principle of measuring pressure distribution or angle of attack. As each aircraft will have a different type of stall warning system, the necessary test will vary by aircraft as well. Here, I will answer based on aircraft that I have experience with, but these concepts should cover the majority of light aircraft.
Aural stall warning systems can generally be divided into two types, pneumatic and electric.
Pneumatic
Pneumatic stall warning systems are found in many light Cessna aircraft, including the 172 and 177. The following system description is from the Cessna 177 Maintenance Manual:
The system is composed of an adjustable plate on the left wing leading edge, connected to a reed type horn by means of plastic tubing. The horn is actuated approximately 5 to 10 miles per hour above stalling speed as a negative air pressure area at wing leading edge causes a reverse flow of air through horn.
See this excerpt from Figure 15-6 in the C177 Maintenance Manual depicting the pneumatic stall warning system and it's location in the aircraft:

To test this type of system, air must be drawn out of the system through the leading edge scoop located in the left wing. The maintenance manual and AD 68-17-04 call for a test procedure as follows:
Prior to flight, test the pneumatic stall warning system and determine if it is functioning properly, [...] by covering the opening in the left wing with a clean cloth, such as a handkerchief, and applying a slight suction by mouth to draw air through the horn. A properly functioning horn will provide a sound that is clearly audible.
The sound is something like that from a kazoo. In actual practice, speaking personally and from my observations, the "clean cloth" is typically dispensed with.
Alternately, a Stall Horn Tester is available for a small price if you would rather not have to put your mouth on a strange airplane.
Failure of these systems will typically be due to a problem either with the horn—such as a loose reed, or with the leading edge scoop—such as a cracked or misaligned scoop.
Electric
Electric systems operate on some of the same principles, but use a movable tab—instead of pneumatic suction—to sense the change pressure distribution. This type of system is found on aircraft such as the Cessna 182, Piper Cherokee, and Beechcraft King Air.
The system operation can be generalized as follows: pressure changes cause the tab to move up thereby sending an electrical signal which will sound a horn in the cockpit. In some cases the tab actuates a microswitch. In more complex systems the tab actuates a transducer which signals a stall warning computer.
The simpler of these types of systems can typically be tested with aircraft electrical power on by manually lifting the tab and listening for the warning horn. With the more complex King Air system, testing is accomplished with a switch in the cockpit which tests the circuitry and horn. In this system, signals from the stall warning transducer are blocked out by a weight on wheels switch when on the ground, with the effect that lifting the tab will not allow for system testing.
Flight Safety (FSI) offers the following system description in their King Air 200/B200 Pilot Training Manual:
The stall warning system senses angle of attack
through a lift transducer actuated by a
vane mounted on the leading edge of the left
wing (Figure 15-10).
Angle of attack from the lift transducer and
flap position signals are processed by the lift
computer to sound the stall warning horn
mounted on the copilot’s side of the cockpit.
The horn sounds when the following conditions
are present:
- Airspeed is 5 to 13 knots above stall,
flaps are fully retracted.
- Airspeed is 5 to 12 knots above stall,
flaps are in the APPROACH (40%)
position.
- Airspeed is 8 to 14 knots above stall,
flaps are fully extended.
The system can be tested prior to flight by
placing the STALL WARN TEST switch, located
on the copilot’s left subpanel, in the
TEST position. This simulates a stall condition
and sounds the warning horn.

Figure 15-10 from the FSI King Air 200/B200 Pilot Training Manual
Other Systems
Other types of systems exist with which I have no actual experience, either as a pilot or mechanic. I offer the following information without much real knowledge of it, but hopefully with good sources. Others more knowledgeable than I might be able to verify it.
The Boeing 737 has a stick shaker type stall warning system to provide the required warning, rather than an aural warning system. The SmartCockpit.com B737 NG Warning Systems document gives the following system description:
Stall Warning System
The stall warning "stick shaker" consists of two eccentric weight motors, one on each control column. They are designed to alert the pilots before a stall develops. The warning is given by vibrating both control columns. The system is armed in flight at all times. The system is deactivated on the ground.
Two independent, identical stall management yaw damper (SMYD) computers determine when stall warning is required based upon:
• alpha vane angle of attack outputs
• ADIRU outputs
• anti-ice controls
• wing configurations
• air/ground sensing
• thrust
• FMC outputs
• mach compensation
The SMYD computers provide outputs for all stall warning to include stick shaker and signals to the pitch limit indicator and airspeed displays and the GPWS windshear detection and alert.
Two test switches are installed in the aft overhead panel. Pushing either of these initiates a self-test of the respective stall warning channel. The No.1 activates the Captain stick shaker, and the No.2 activates the F/O stick shaker. Either stick shaker vibrates both columns through column interconnects.
The same document further defines the test procedure:
STALL WARNING TEST Switches
Push – on ground with AC power available: each test switch tests its respective stall management yaw damper (SMYD) computer. No.1 SMYD computer shakes Captain's control column, No.2 SMYD computer shakes First Officer's control column. Vibrations can be felt on both columns
• inhibited while airborne